/** * Get the set of properties that match a specified pattern. The match pattern accepts a single * '*' char anywhere in the pattern. If the '*' is placed somewhere in the middle of the pattern, * then then the subset will contain properties that startWith everything before the '*' and end * with everything after the '*'. * * <p>Sample property patterns: * * <table> * <tr><td>*.bar<td> returns the subset of properties that end with '.bar' * <tr><td>bar.*<td> returns the subset of properties that begin with 'bar.' * <tr><td>foo*bar<td> returns the subset of properties that begin with 'foo' and end with 'bar' * </table> * * @param propPattern a pattern with 0 or 1 '*' chars. * @return the subset of properties that match the specified pattern. Note that changing the * properties in the returned subset will not affect this object. */ public Properties getProperties(String propPattern) { Properties props = new Properties(); int index = propPattern.indexOf("*"); if (index == -1) { String value = getProperty(propPattern); if (value != null) { props.put(propPattern, value); } } else { String startsWith = propPattern.substring(0, index); String endsWith; if (index == propPattern.length() - 1) { endsWith = null; } else { endsWith = propPattern.substring(index + 1); } Enumeration names = propertyNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); if (name.startsWith(startsWith)) { if (endsWith == null) { props.put(name, getProperty(name)); } else if (name.endsWith(endsWith)) { props.put(name, getProperty(name)); } } } } return props; }
private XmlUIElement getXmlUIElementFor(String typeArg) { if (typeToClassMappingProp == null) { setUpMappingsHM(); } String clsName = (String) typeToClassMappingProp.get(typeArg); if ((clsName != null) && !(clsName.equals("*NOTFOUND*")) && !(clsName.equals("*EXCEPTION*"))) { try { Class cls = Class.forName(clsName); return (XmlUIElement) cls.newInstance(); } catch (Throwable th) { typeToClassMappingProp.put(typeArg, "*EXCEPTION*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "{0} occurred when trying to get the XmlUIElement for type : {1}"), new Object[] {th.getClass().getName(), typeArg})); th.printStackTrace(); return null; } } else if (clsName == null) { typeToClassMappingProp.put(typeArg, "*NOTFOUND*"); showErrorMessage( MessageFormat.format( ProvClientUtils.getString( "The type {0} does not have the corresponding XMLUIElement specified in the TypeToUIElementMapping.txt file"), new Object[] {typeArg})); } return null; }
/** store the given RenderingHints to a Properties object */ public static void formatRenderingHints(RenderingHints rh, Properties preferences) { if (rh.get(RenderingHints.KEY_ANTIALIASING).equals(RenderingHints.VALUE_ANTIALIAS_ON)) preferences.put("rendering.antialiasing", "on"); else if (rh.get(RenderingHints.KEY_ANTIALIASING).equals(RenderingHints.VALUE_ANTIALIAS_OFF)) preferences.put("rendering.antialiasing", "off"); if (rh.get(RenderingHints.KEY_TEXT_ANTIALIASING).equals(RenderingHints.VALUE_TEXT_ANTIALIAS_ON)) preferences.put("rendering.text-antialiasing", "on"); else if (rh.get(RenderingHints.KEY_TEXT_ANTIALIASING) .equals(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)) preferences.put("rendering.text-antialiasing", "off"); if (rh.get(RenderingHints.KEY_RENDERING).equals(RenderingHints.VALUE_RENDER_SPEED)) preferences.put("rendering.render", "speed"); else if (rh.get(RenderingHints.KEY_RENDERING).equals(RenderingHints.VALUE_RENDER_QUALITY)) preferences.put("rendering.render", "quality"); if (rh.get(RenderingHints.KEY_DITHERING).equals(RenderingHints.VALUE_DITHER_ENABLE)) preferences.put("rendering.dither", "on"); else if (rh.get(RenderingHints.KEY_DITHERING).equals(RenderingHints.VALUE_DITHER_DISABLE)) preferences.put("rendering.dither", "off"); if (rh.get(RenderingHints.KEY_FRACTIONALMETRICS) .equals(RenderingHints.VALUE_FRACTIONALMETRICS_ON)) preferences.put("rendering.fractional-metrics", "on"); else if (rh.get(RenderingHints.KEY_FRACTIONALMETRICS) .equals(RenderingHints.VALUE_FRACTIONALMETRICS_OFF)) preferences.put("rendering.fractional-metrics", "off"); }
public void mail(String toAddress, String subject, String body) { Properties props = new Properties(); props.put("mail.smtp.host", host); props.put("mail.smtp.port", port); props.put("mail.smtp.ssl.enable", true); Authenticator authenticator = null; if (login) { props.put("mail.smtp.auth", true); authenticator = new Authenticator() { private PasswordAuthentication pa = new PasswordAuthentication(username, password); @Override public PasswordAuthentication getPasswordAuthentication() { return pa; } }; } Session s = Session.getInstance(props, authenticator); s.setDebug(debug); MimeMessage email = new MimeMessage(s); try { email.setFrom(new InternetAddress(from)); email.setRecipient(Message.RecipientType.TO, new InternetAddress(toAddress)); email.setSubject(subject); email.setSentDate(new Date()); email.setText(body); Transport.send(email); } catch (MessagingException ex) { ex.printStackTrace(); } }
private void setTarget(Info info) { String factionInfo = info.getMessage().substring(11); String[] splitInfo = factionInfo.split("/"); if (splitInfo.length != 2) { info.sendMessage("usage for !setTarget is !setTarget <faction>/<location>"); } else { raidTarget.put(info.getChannel(), splitInfo[0]); raidLocation.put(info.getChannel(), splitInfo[1]); target(info); } }
/** This method creates a properties object containing the definition of the data store. */ public Properties getProperties() { Properties p = super.getProperties(); String desc = "base."; p.put(desc + "updateMethod", getIntProperty(_updateMethod)); p.put(desc + "checkConcurrency", getBoolProperty(_checkConcurrency)); p.put(desc + "useBind", getBoolProperty(_useBind)); p.put(desc + "maxRows", getIntProperty(_maxRows)); p.put(desc + "remoteID", getStringProperty(_remoteID)); return p; }
public static void testSpecialConversions() throws URISyntaxException { Properties p = new Properties(); p.put("enumv", "A"); p.put("pattern", ".*"); p.put("clazz", "java.lang.Object"); p.put("constructor", "http://www.aQute.biz"); SpecialConversions trt = Configurable.createConfigurable(SpecialConversions.class, (Map<Object, Object>) p); assertEquals(SpecialConversions.X.A, trt.enumv()); assertEquals(".*", trt.pattern().pattern()); assertEquals(Object.class, trt.clazz()); assertEquals(new URI("http://www.aQute.biz"), trt.constructor()); }
public void testCreateIllProv() throws Exception { File dir = getTempDir(); File file = new File(dir, "test.ks"); Properties p = initProps(); p.put(KeyStoreUtil.PROP_KEYSTORE_FILE, file.toString()); p.put(KeyStoreUtil.PROP_KEYSTORE_TYPE, "JKS"); p.put(KeyStoreUtil.PROP_KEYSTORE_PROVIDER, "not_a_provider"); assertFalse(file.exists()); try { KeyStoreUtil.createKeyStore(p); fail("Illegal keystore type should throw"); } catch (NoSuchProviderException e) { } assertFalse(file.exists()); }
private void updateLinuxServiceInstaller() { try { File dir = new File(directory, "CTP"); if (suppressFirstPathElement) dir = dir.getParentFile(); Properties props = new Properties(); String ctpHome = dir.getAbsolutePath(); cp.appendln(Color.black, "...CTP_HOME: " + ctpHome); ctpHome = ctpHome.replaceAll("\\\\", "\\\\\\\\"); props.put("CTP_HOME", ctpHome); File javaHome = new File(System.getProperty("java.home")); String javaBin = (new File(javaHome, "bin")).getAbsolutePath(); cp.appendln(Color.black, "...JAVA_BIN: " + javaBin); javaBin = javaBin.replaceAll("\\\\", "\\\\\\\\"); props.put("JAVA_BIN", javaBin); File linux = new File(dir, "linux"); File install = new File(linux, "ctpService-ubuntu.sh"); cp.appendln(Color.black, "Linux service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); String bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); setFileText(install, bat); // If this is an ISN installation, put the script in the correct place. String osName = System.getProperty("os.name").toLowerCase(); if (programName.equals("ISN") && !osName.contains("windows")) { install = new File(linux, "ctpService-red.sh"); cp.appendln(Color.black, "ISN service installer:"); cp.appendln(Color.black, "...file: " + install.getAbsolutePath()); bat = getFileText(install); bat = replace(bat, props); // do the substitutions bat = bat.replace("\r", ""); File initDir = new File("/etc/init.d"); File initFile = new File(initDir, "ctpService"); if (initDir.exists()) { setOwnership(initDir, "edge", "edge"); setFileText(initFile, bat); initFile.setReadable(true, false); // everybody can read //Java 1.6 initFile.setWritable(true); // only the owner can write //Java 1.6 initFile.setExecutable(true, false); // everybody can execute //Java 1.6 } } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unable to update the Linux service ctpService.sh file"); } }
/** Called once when ImageJ quits. */ public void savePreferences(Properties prefs) { Point loc = getLocation(); prefs.put(IJ_X, Integer.toString(loc.x)); prefs.put(IJ_Y, Integer.toString(loc.y)); // prefs.put(IJ_WIDTH, Integer.toString(size.width)); // prefs.put(IJ_HEIGHT, Integer.toString(size.height)); }
public static void main(String[] args) throws IOException { PrintWriter out; if (args.length > 1) { out = new PrintWriter(args[1]); } else { out = new PrintWriter(System.out); } PrintWriter xmlOut = null; if (args.length > 2) { xmlOut = new PrintWriter(args[2]); } Properties props = new Properties(); props.put("annotators", "tokenize, ssplit, pos, lemma, ner,parse"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); Annotation annotation; if (args.length > 0) { annotation = new Annotation(IOUtils.slurpFileNoExceptions(args[0])); } else { annotation = new Annotation( "Kosgi Santosh sent an email to Stanford University. He didn't get a reply."); } pipeline.annotate(annotation); pipeline.prettyPrint(annotation, out); }
public void send() { // Your SMTP server address here. String smtpHost = "myserver.jeffcorp.com"; // The sender's email address String from = "*****@*****.**"; // The recepients email address String to = "*****@*****.**"; Properties props = new Properties(); // The protocol to use is SMTP props.put("mail.smtp.host", smtpHost); Session session = Session.getDefaultInstance(props, null); try { InternetAddress[] address = {new InternetAddress(to)}; MimeMessage message; message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO, to); message.setSubject("Hello from Jeff"); message.setSentDate(sendDate); message.setText("Hello Jeff, \nHow are things going?"); Transport.send(message); System.out.println("email has been sent."); } catch (Exception e) { System.out.println(e); } }
/** Constructor for StanfordLemmatizer. */ public StanfordLemmatizer() { // Create StanfordCoreNLP object properties, with POS tagging // (required for lemmatization), and lemmatization Properties props; props = new Properties(); props.put("annotators", "tokenize, ssplit, pos, lemma"); /* * This is a pipeline that takes in a string and returns various * analyzed linguistic forms. The String is tokenized via a tokenizer * (such as PTBTokenizerAnnotator), and then other sequence model style * annotation can be used to add things like lemmas, POS tags, and named * entities. These are returned as a list of CoreLabels. Other analysis * components build and store parse trees, dependency graphs, etc. * * This class is designed to apply multiple Annotators to an Annotation. * The idea is that you first build up the pipeline by adding * Annotators, and then you take the objects you wish to annotate and * pass them in and get in return a fully annotated object. * * StanfordCoreNLP loads a lot of models, so you probably only want to * do this once per execution */ this.pipeline = new StanfordCoreNLP(props); }
/** Sends Emails to Customers who have not submitted their Bears */ public static void BearEmailSendMessage(String msgsubject, String msgText, String msgTo) { try { BearFrom = props.getProperty("BEARFROM"); // To = props.getProperty("TO"); SMTPHost = props.getProperty("SMTPHOST"); Properties mailprops = new Properties(); mailprops.put("mail.smtp.host", SMTPHost); // create some properties and get the default Session Session session = Session.getDefaultInstance(mailprops, null); // create a message Message msg = new MimeMessage(session); // set the from InternetAddress from = new InternetAddress(BearFrom); msg.setFrom(from); InternetAddress[] address = InternetAddress.parse(msgTo); msg.setRecipients(Message.RecipientType.TO, address); msg.setSubject(msgsubject); msg.setContent(msgText, "text/plain"); Transport.send(msg); } // end try catch (MessagingException mex) { USFEnv.getLog().writeCrit("Message not sent", null, null); } catch (Exception ex) { USFEnv.getLog().writeCrit("Message not sent", null, null); } } // end BearEmailSendMessage
private void initializeDatabaseContext() throws EmanagerDatabaseException { logger.debug("Enter"); Properties properties; SybConnectionPoolDataSource poolDataSource; properties = new Properties(); poolDataSource = new com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource(); poolDataSource.setUser(userAccount); poolDataSource.setPassword(password); poolDataSource.setDatabaseName(databaseName); poolDataSource.setServerName(databaseHost); poolDataSource.setPortNumber(connectionPort); poolDataSource.setDescription(connectionPoolDescription); properties.put("user", userAccount); properties.put("password", password); properties.put("APPLICATIONNAME", clientAppName); // fix // hopefully these have defaults // properties.put("USE_METADATA", userMetaData); // properties.put("REPEAT_READ", useRepeatRead); // properties.put("CHARSET_CONVERTER_CLASS", charsetConverter); properties.put("server", "jdbc:sybase:Tds:" + databaseHost + ":" + connectionPort); try { poolDataSource.setConnectionProperties(properties); // jndiContext.bind("jdbc/protoDB", poolDataSource); jndiContext.bind(JNDIContextName, poolDataSource); } catch (Exception ex) { String logString; EmanagerDatabaseException ede; logString = EmanagerDatabaseStatusCode.UnableToBindJNDIContext.getStatusCodeDescription() + ex.getMessage(); logger.fatal(logString); ede = new EmanagerDatabaseException( EmanagerDatabaseStatusCode.UnableToBindJNDIContext, logString); throw ede; } }
public static void basic_putenv(Object name, Object value) { String name_string = SmartEiffelRuntime.NullTerminatedBytesToString(name); String value_string = SmartEiffelRuntime.NullTerminatedBytesToString(value); Properties props = System.getProperties(); props.put(name_string, value_string); System.setProperties(props); return; }
static <T> T set(Class<T> interf, Object value) { Properties p = new Properties(); Method ms[] = interf.getMethods(); for (Method m : ms) { p.put(m.getName(), value); } return Configurable.createConfigurable(interf, (Map<Object, Object>) p); }
void configureProxy() { if (Prefs.useSystemProxies) { try { System.setProperty("java.net.useSystemProxies", "true"); } catch (Exception e) { } } else { String server = Prefs.get("proxy.server", null); if (server == null || server.equals("")) return; int port = (int) Prefs.get("proxy.port", 0); if (port == 0) return; Properties props = System.getProperties(); props.put("proxySet", "true"); props.put("http.proxyHost", server); props.put("http.proxyPort", "" + port); } // new ProxySettings().logProperties(); }
// parse a property line private String loadProperty(String prop, int lineNumber) { String key; String value; int prop_len = prop.length(); int prop_index = 0; // key for (; prop_index < prop_len; prop_index++) { char current = prop.charAt(prop_index); if (current == '\\') prop_index++; else if (terminators.indexOf(current) != -1) break; } key = prop.substring(0, prop_index); key = removeBadChars(prop, key, false); key = unescape(key); key = key.trim(); // got key now go to first non-whitespace for (; prop_index < prop.length() && whitespace.indexOf(prop.charAt(prop_index)) != -1; prop_index++) ; try { // also skip : or = if (prop.charAt(prop_index) == ':' || prop.charAt(prop_index) == '=') { prop_index++; // skip any more whitespace for (; prop_index < prop.length() && whitespace.indexOf(prop.charAt(prop_index)) != -1; prop_index++) ; } } catch (StringIndexOutOfBoundsException ex) { return null; } int value_start = prop_index; // read value for (; prop_index < prop.length(); prop_index++) { char current = prop.charAt(prop_index); if (current == '\\') prop_index++; else if (valterminators.indexOf(current) != -1) break; } value = prop.substring(value_start, prop_index); value = removeBadChars(prop, value, true); value = unescape(value); // System.out.println("|" + key + "|" + value + "|"); if (!super.containsKey(key)) keys.addElement(key); super.put(key, value); lines.put(key, new Integer(lineNumber)); return key; }
public void testStoreJks() throws Exception { File dir = getTempDir(); File file = new File(dir, "test.ks"); Properties p = initProps(); p.put(KeyStoreUtil.PROP_KEYSTORE_FILE, file.toString()); p.put(KeyStoreUtil.PROP_KEYSTORE_TYPE, "JKS"); p.put(KeyStoreUtil.PROP_KEYSTORE_PROVIDER, ""); assertFalse(file.exists()); KeyStore ks = KeyStoreUtil.createKeyStore(p); assertTrue(file.exists()); KeyStore ks2 = loadKeyStore(ks.getType(), file, PASSWD); List aliases = ListUtil.fromIterator(new EnumerationIterator(ks2.aliases())); assertIsomorphic(SetUtil.set("mykey", "mycert"), SetUtil.theSet(aliases)); assertNotNull(ks2.getCertificate("mycert")); assertNull(ks2.getCertificate("foocert")); assertEquals("JKS", ks2.getType()); }
/** * Take all the properties and translate them to actual values. This method takes the set * properties and traverse them over all entries, including the default properties for that * properties. The values no longer contain macros. * * @return A new Properties with the flattened values */ public Properties getFlattenedProperties() { // Some macros only work in a lower processor, so we // do not report unknown macros while flattening flattening = true; try { Properties flattened = new Properties(); Properties source = domain.getProperties(); for (Enumeration<?> e = source.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); if (!key.startsWith("_")) if (key.startsWith("-")) flattened.put(key, source.getProperty(key)); else flattened.put(key, process(source.getProperty(key))); } return flattened; } finally { flattening = false; } }
private void sendEmail(Task.Status exitStatus, File logFile) throws IOException, MessagingException, TemplateException { String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer(); if (smtpServer == null || smtpServer.isEmpty()) { return; } String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail(); String recipientsEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail(); String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword(); String subject = "REPOX Data Source ingesting finished. Exit status: " + exitStatus.toString(); EmailSender emailSender = new EmailSender(); String pathIngestFile = URLDecoder.decode( Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(), "ISO-8859-1"); emailSender.setTemplate( pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest"); HashMap map = new HashMap<String, String>(); map.put("exitStatus", exitStatus.toString()); map.put("id", id); JavaMailSenderImpl mail = new JavaMailSenderImpl(); // mail.setUsername(fromEmail); mail.setUsername(recipientsEmail); mail.setPassword(adminMailPass); mail.setPort(25); Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); mail.setJavaMailProperties(props); emailSender.setMailSender(mail); emailSender.sendEmail(recipientsEmail, fromEmail, subject, map, logFile.getAbsolutePath()); }
public Properties getUserInputValues() { Properties prop = new Properties(); for (int i = 0; i < uiList.size(); i++) { UserInput ui = (UserInput) uiList.get(i); XmlUIElement el = (XmlUIElement) uiElementsList.get(i); ui.setValue(el.getValue()); prop.put("$UserInput$" + ui.getID(), el.getValue()); } return prop; }
public static void main(String[] args) throws Exception { String smtpServer = RepoxContextUtil.getRepoxManager().getConfiguration().getSmtpServer(); if (smtpServer == null || smtpServer.isEmpty()) { return; } String fromEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getDefaultEmail(); String recipientsEmail = RepoxContextUtil.getRepoxManager().getConfiguration().getAdministratorEmail(); String adminMailPass = RepoxContextUtil.getRepoxManager().getConfiguration().getMailPassword(); String subject = "REPOX Data Source ingesting finished. Exit status: "; EmailSender emailSender = new EmailSender(); String pathIngestFile = URLDecoder.decode( Thread.currentThread().getContextClassLoader().getResource("ingest.html.ftl").getFile(), "ISO-8859-1"); emailSender.setTemplate( pathIngestFile.substring(0, pathIngestFile.lastIndexOf("/")) + "/ingest"); HashMap map = new HashMap<String, String>(); map.put("exitStatus", "OK"); map.put("id", "1111"); JavaMailSenderImpl mail = new JavaMailSenderImpl(); mail.setUsername(recipientsEmail); mail.setPassword(adminMailPass); mail.setPort(25); Properties props = System.getProperties(); props.put("mail.smtp.host", smtpServer); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "false"); mail.setJavaMailProperties(props); emailSender.setMailSender(mail); emailSender.sendEmail( recipientsEmail, fromEmail, subject, map, "C:\\Users\\GPedrosa\\Desktop\\indexSec.txt"); }
public static void main(String[] args) { try { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.PROVIDER_URL, "10.10.10.13:1100,10.10.10.14:1100"); // p.put(Context.PROVIDER_URL, "localhost:1100"); p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces"); InitialContext ctx = new InitialContext(p); StatelessSessionHome statelessSessionHome = (StatelessSessionHome) ctx.lookup("nextgen.StatelessSession"); EnterpriseEntityHome cmpHome = (EnterpriseEntityHome) ctx.lookup("nextgen.EnterpriseEntity"); StatelessSession statelessSession = statelessSessionHome.create(); EnterpriseEntity cmp = null; try { cmp = cmpHome.findByPrimaryKey("bill"); } catch (Exception ex) { cmp = cmpHome.create("bill"); } int count = 0; while (true) { System.out.println(statelessSession.callBusinessMethodB()); try { cmp.setOtherField(count++); } catch (Exception ex) { System.out.println("exception, trying to create it: " + ex); cmp = cmpHome.create("bill"); cmp.setOtherField(count++); } System.out.println("Entity: " + cmp.getOtherField()); Thread.sleep(2000); } } catch (NamingException nex) { if (nex.getRootCause() != null) { nex.getRootCause().printStackTrace(); } } catch (Exception ex) { ex.printStackTrace(); } }
/** * Gets a new Properties object initialised with the values from a Map. A null input will return * an empty properties object. * * @param map the map to convert to a Properties object * @return the properties object */ public static Properties toProperties(Map map) { Properties answer = new Properties(); if (map != null) { for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) { Map.Entry entry = (Map.Entry) iter.next(); Object key = entry.getKey(); Object value = entry.getValue(); answer.put(key, value); } } return answer; }
private Properties writeDefaultDesktopAgentPropertiesFile(File objPropertiesFile) throws InvalidPropertiesFormatException, IOException { Properties tempProps = new Properties(); FileOutputStream fos = new FileOutputStream(objPropertiesFile); tempProps.put("desktop_agent_left", "0"); tempProps.put("desktop_agent_top", "0"); tempProps.put("desktop_agent_width", "300"); tempProps.put("desktop_agent_height", "450"); tempProps.put("desktop_agent_use_custom_window_controls", "false"); tempProps.put("desktop_agent_background_color", "808080"); tempProps.put("desktop_agent_buttons_background_color", "808080"); tempProps.put("agents_directory", "Desktop Agent Agents"); tempProps.put("number_of_agents", "1"); tempProps.put("agent_files", "GreetingAgent.agent"); tempProps.storeToXML(fos, "Desktop Agent Properties File", "UTF-8"); return tempProps; }
public static void sfSendEmail(String subject, String message) throws Exception { String SMTP_HOST_NAME = "smtp.gmail.com"; String SMTP_PORT = "465"; // message = "Test Email Notification From Monitor"; // subject = "Test Email Notification From Monitor"; String from = "*****@*****.**"; String[] recipients = { "*****@*****.**", "*****@*****.**", "*****@*****.**" }; String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; // String[] recipients = { "*****@*****.**"}; // String[] recipients = { "*****@*****.**", "*****@*****.**", // "*****@*****.**", "*****@*****.**", "*****@*****.**", // "*****@*****.**", "*****@*****.**"}; // String[] recipients = {"*****@*****.**"}; Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); boolean debug = true; Properties props = new Properties(); props.put("mail.smtp.host", SMTP_HOST_NAME); props.put("mail.smtp.auth", "true"); // props.put("mail.debug", "true"); props.put("mail.smtp.port", SMTP_PORT); props.put("mail.smtp.socketFactory.port", SMTP_PORT); props.put("mail.smtp.socketFactory.class", SSL_FACTORY); props.put("mail.smtp.socketFactory.fallback", "false"); Session session = Session.getDefaultInstance( props, new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication( "*****@*****.**", "els102sensorweb"); } }); // session.setDebug(debug); Message msg = new MimeMessage(session); InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i < recipients.length; i++) { addressTo[i] = new InternetAddress(recipients[i]); } msg.setRecipients(Message.RecipientType.TO, addressTo); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); System.out.println("Sucessfully Sent mail to All Users"); }
public void testConfig() throws Exception { MyMockLockssRepositoryImpl repo1 = makeRepo("foo"); assertEquals(RepositoryManager.DEFAULT_MAX_PER_AU_CACHE_SIZE, repo1.nodeCacheSize); ConfigurationUtil.setFromArgs(RepositoryManager.PARAM_MAX_PER_AU_CACHE_SIZE, "4"); MyMockLockssRepositoryImpl repo2 = makeRepo("bar"); assertEquals(4, repo1.nodeCacheSize); assertEquals(4, repo2.nodeCacheSize); repo1.cnt = 0; ConfigurationUtil.setFromArgs(RepositoryManager.PARAM_MAX_PER_AU_CACHE_SIZE, "37"); assertEquals(37, repo1.nodeCacheSize); assertEquals(37, repo2.nodeCacheSize); assertEquals(1, repo1.cnt); // ensure setNodeCacheSize doesn't get called if param doesn't change ConfigurationUtil.setFromArgs( RepositoryManager.PARAM_MAX_PER_AU_CACHE_SIZE, "37", "org.lockss.somethingElse", "bar"); assertEquals(1, repo1.cnt); PlatformUtil.DF warn = mgr.getDiskWarnThreshold(); PlatformUtil.DF full = mgr.getDiskFullThreshold(); assertEquals(5000 * 1024, warn.getAvail()); assertEquals(0.98, warn.getPercent(), .00001); assertEquals(100 * 1024, full.getAvail()); assertEquals(0.99, full.getPercent(), .00001); Properties p = new Properties(); p.put(RepositoryManager.PARAM_DISK_WARN_FRRE_MB, "17"); p.put(RepositoryManager.PARAM_DISK_WARN_FRRE_PERCENT, "20"); p.put(RepositoryManager.PARAM_DISK_FULL_FRRE_MB, "7"); p.put(RepositoryManager.PARAM_DISK_FULL_FRRE_PERCENT, "10"); ConfigurationUtil.setCurrentConfigFromProps(p); warn = mgr.getDiskWarnThreshold(); full = mgr.getDiskFullThreshold(); assertEquals(17 * 1024, warn.getAvail()); assertEquals(0.80, warn.getPercent(), .00001); assertEquals(7 * 1024, full.getAvail()); assertEquals(0.90, full.getPercent(), .00001); }
/* * Initialize to default values, if <java.home>/lib/java.security * is not found. */ private static void initializeStatic() { props.put("security.provider.1", "sun.security.provider.Sun"); props.put("security.provider.2", "sun.security.rsa.SunRsaSign"); props.put("security.provider.3", "com.sun.net.ssl.internal.ssl.Provider"); props.put("security.provider.4", "com.sun.crypto.provider.SunJCE"); props.put("security.provider.5", "sun.security.jgss.SunProvider"); props.put("security.provider.6", "com.sun.security.sasl.Provider"); }