List of usage examples for java.util Properties get
@Override
public Object get(Object key)
From source file:com.hs.mail.mailet.RemoteDelivery.java
/** * Initialize the mailet/*from w ww .j a v a 2 s . com*/ */ public void init(MailetContext context) { super.init(context); Properties props = new Properties(); Properties sysprops = System.getProperties(); for (Object key : sysprops.keySet()) { if (((String) key).startsWith("mail.")) { props.put(key, sysprops.get(key)); } } if (this.debug) props.setProperty("mail.debug", "true"); props.setProperty("mail.smtp.timeout", smtpTimeout + ""); props.setProperty("mail.smtp.connectiontimeout", connectionTimeout + ""); props.setProperty("mail.smtp.sendpartial", String.valueOf(sendPartial)); props.setProperty("mail.smtp.localhost", Config.getHelloName()); this.maxRetries = (int) Config.getNumberProperty("max_retry_count", 3); this.session = Session.getInstance(props, null); this.session.setDebug(this.debug); this.gateway = Config.getProperty("smtp_gateway", null); this.authUser = Config.getProperty("smtp_gateway_username", null); this.authPass = Config.getProperty("smtp_gateway_password", null); }
From source file:edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageImpl.java
/** * Load the namespaces file from the disk. It's easy to load into a * {@link Properties}, but we need to convert it to a {@link Map}. *///from ww w . j a v a2 s. com private Map<Character, String> readNamespaces() throws IOException { Reader reader = null; try { reader = new FileReader(this.namespaceFile); Properties props = new Properties(); props.load(reader); Map<Character, String> map = new HashMap<Character, String>(); for (Object key : props.keySet()) { char keyChar = key.toString().charAt(0); map.put(keyChar, (String) props.get(key)); } return map; } catch (Exception e) { throw new IOException("Problem loading the namespace file."); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { e.printStackTrace(); } } } }
From source file:in.gov.uidai.auth.sampleapp.UIDAIClient.java
private void loadPreferences() { FileInputStream is = null;//from www . jav a 2 s . co m try { File preferencesFile = new File("authclient.properties"); if (preferencesFile.exists()) { is = new FileInputStream(preferencesFile); Properties p = new Properties(); p.load(is); this.authClientProperties = new HashMap<String, String>(); if (p.get("authServerUrl") != null) { this.authClientProperties.put("authServerUrl", p.get("authServerUrl").toString()); } if (p.get("otpServerUrl") != null) { this.authClientProperties.put("otpServerUrl", p.get("otpServerUrl").toString()); } if (p.get("auaCode") != null) { this.authClientProperties.put("auaCode", p.get("auaCode").toString()); } if (p.get("signKeyStore") != null) { this.authClientProperties.put("signKeyStore", p.get("signKeyStore").toString()); } if (p.get("sa") != null) { this.authClientProperties.put("sa", p.get("sa").toString()); } if (p.get("licenseKey") != null) { this.authClientProperties.put("licenseKey", p.get("licenseKey").toString()); } if (p.get("asaLicenseKey") != null) { this.authClientProperties.put("asaLicenseKey", p.get("asaLicenseKey").toString()); } if (p.get("terminalId") != null) { this.authClientProperties.put("terminalId", p.get("terminalId").toString()); } if (p.get("publicKeyFile") != null) { this.authClientProperties.put("publicKeyFile", p.get("publicKeyFile").toString()); } if (p.get("publicKeyFileDSIG") != null && !StringUtils.isEmpty(p.get("publicKeyFileDSIG").toString())) { this.authClientProperties.put("publicKeyFileDSIG", p.get("publicKeyFileDSIG").toString()); } else { this.authClientProperties.put("publicKeyFile", p.get("publicKeyFile").toString()); } if (p.get("usesPi") != null) { this.authClientProperties.put("usesPi", p.get("usesPi").toString()); } if (p.get("usesPa") != null) { this.authClientProperties.put("usesPa", p.get("usesPa").toString()); } if (p.get("usesPfa") != null) { this.authClientProperties.put("usesPfa", p.get("usesPfa").toString()); } if (p.get("usesPin") != null) { this.authClientProperties.put("usesPin", p.get("usesPin").toString()); } if (p.get("usesOtp") != null) { this.authClientProperties.put("usesOtp", p.get("usesOtp").toString()); } if (p.get("usesBio") != null) { this.authClientProperties.put("usesBio", p.get("usesBio").toString()); } if (p.get("usesBioFMR") != null) { this.authClientProperties.put("usesBioFMR", p.get("usesBioFMR").toString()); } if (p.get("usesBioFIR") != null) { this.authClientProperties.put("usesBioFIR", p.get("usesBioFIR").toString()); } if (p.get("usesBioIIR") != null) { this.authClientProperties.put("usesBioIIR", p.get("usesBioIIR").toString()); } if (p.get("signatureAlias") != null) { this.authClientProperties.put("signatureAlias", p.get("signatureAlias").toString()); } if (p.get("signaturePassword") != null) { this.authClientProperties.put("signaturePassword", p.get("signaturePassword").toString()); } if (p.get("udc") != null) { this.authClientProperties.put("udc", p.get("udc").toString()); } if (p.get("fdc") != null) { this.authClientProperties.put("fdc", p.get("fdc").toString()); } if (p.get("idc") != null) { this.authClientProperties.put("idc", p.get("idc").toString()); } if (p.get("pincode") != null) { this.authClientProperties.put("pincode", p.get("pincode").toString()); } if (p.get("lot") != null) { this.authClientProperties.put("lot", p.get("lot").toString()); } if (p.get("lov") != null) { this.authClientProperties.put("lov", p.get("lov").toString()); } if (p.get("publicIP") != null) { this.authClientProperties.put("publicIP", p.get("publicIP").toString()); } if (p.get("useSSK") != null) { this.authClientProperties.put("useSSK", p.get("useSSK").toString()); } if (p.get("pidType") != null) { this.authClientProperties.put("pidType", p.get("pidType").toString()); } if (p.get("bfdServerUrl") != null) { this.authClientProperties.put("bfdServerUrl", p.get("bfdServerUrl").toString()); } } } catch (IOException ex) { ex.printStackTrace(); } finally { try { if (is != null) { is.close(); } } catch (IOException ex) { ex.printStackTrace(); } } }
From source file:com.google.enterprise.connector.salesforce.security.BaseAuthorizationManager.java
/** * Connector manager sends a collection of documentIDs to the connector * to authorize for an authenticated context * * @param col Collection the docIDs to authorize * @param id AuthenticationIdentity the identity to auth * @return Collection of docs that are authorized *//*from ww w .jav a 2 s . c o m*/ public Collection authorizeDocids(Collection col, AuthenticationIdentity id) { logger.log(Level.FINER, " SalesForceAuthorizationManager. authorizeDocids called for " + id.getUsername()); //first see if we have a callable authorization module to try String callable_az_module = System .getProperty(BaseConstants.CALLABLE_AZ + "_" + connector.getInstanceName()); if (callable_az_module != null) { logger.log(Level.FINE, "Using Loadable Authorization Module : " + callable_az_module); try { Class cls = Class.forName(callable_az_module); java.lang.reflect.Constructor co = cls.getConstructor(); IAuthorizationModule icau = (IAuthorizationModule) co.newInstance(); Collection auth_col = icau.authorizeDocids(col, id.getUsername()); Collection ret_col = new ArrayList(); for (Iterator i = auth_col.iterator(); i.hasNext();) { String did = (String) i.next(); AuthorizationResponse ap = new AuthorizationResponse(true, did); ret_col.add(ap); } return ret_col; } catch (Exception ex) { logger.log(Level.SEVERE, "Unable to load Authorization Module " + callable_az_module); } } else { logger.log(Level.FINER, "Using Default Authorization Module"); } Iterator itr = col.iterator(); logger.log(Level.FINER, " AUTHORIZING BATCH OF : " + col.size() + " documents"); //vector to hold the list of docs that will eventually get authorized Vector v_docIDs = new Vector(); //create a string of 'docid1','docid2','docid3' to send into the AZ query String doc_wildcard = ""; while (itr.hasNext()) { String docID = (String) itr.next(); v_docIDs.add(docID); doc_wildcard = doc_wildcard + "'" + docID + "'"; if (itr.hasNext()) doc_wildcard = doc_wildcard + ","; } //initialize the collection for the response Collection col_resp = new ArrayList(); String query = connector.getAzquery(); //substitute the doc IDs into the AZ query String modified_az_query = query.replace("$DOCIDS", doc_wildcard); modified_az_query = modified_az_query.replace("$USERID", id.getUsername()); logger.log(Level.FINER, "Attempting Authorizing DocList " + modified_az_query); //get ready to submit the query SFQuery sfq = new SFQuery(); //get the user's sessionID, login server thats in context //this step maynot be necessary if we use the connector's login context //instead of the users... //TODO: figure out which way is better later on Properties session_props = connector.getUserSession(id.getUsername()); //not that it matters, how did the user authenticate.. //if its strong (i.e, we got a session ID, we can submit a full AZ query) String auth_strength = (String) session_props.get(BaseConstants.AUTHENTICATION_TYPE); if (auth_strength.equals(BaseConstants.STRONG_AUTHENTICATION)) { logger.log(Level.FINER, "Using Strong Authentication"); try { //following section is used if we want to AZ using the connectors authenticated super context //its commented out for now but we'll touch on this later // if (connector.getSessionID().equalsIgnoreCase("")){ // SalesForceLogin sfl = new SalesForceLogin(connector.getUsername(),connector.getPassword(),connector.getLoginsrv()); // if (sfl.isLoggedIn()){ // connector.setSessionID(sfl.getSessionID()); // connector.setEndPointServer(sfl.getEndPointServer()); // } // } //for connector-managed sessions //todo figure out someway to purge the older sessions logger.log(Level.INFO, "Submitting [" + (String) session_props.getProperty(BaseConstants.LOGIN_SERVER) + "] [" + (String) session_props.getProperty(BaseConstants.SESSIONID) + "]"); org.w3c.dom.Document az_resp = sfq.submitStatement(modified_az_query, BaseConstants.QUERY_TYPE, (String) session_props.getProperty(BaseConstants.LOGIN_SERVER), (String) session_props.getProperty(BaseConstants.SESSIONID)); //if using system session to check AZ //org.w3c.dom.Document az_resp = sfq.submitStatement(modified_az_query, BaseConstants.QUERY_TYPE,connector.getEndPointServer() , connector.getSessionID()); //now transform the AZ SOAP response into the canonical form using //the AZ XLST provided. String encodedXSLT = connector.getAzxslt(); byte[] decode = org.apache.commons.codec.binary.Base64.decodeBase64(encodedXSLT.getBytes()); org.w3c.dom.Document az_xsl = Util.XMLStringtoDoc(new String(decode)); logger.log(Level.FINER, "AZ Query Response " + Util.XMLDoctoString(az_resp)); Document tx_xml = Util.TransformDoctoDoc(az_resp, az_xsl); tx_xml.getDocumentElement().normalize(); logger.log(Level.FINER, "AZ transform result for " + id.getUsername() + " " + Util.XMLDoctoString(tx_xml)); //TODO...figure out why I can use tx_xml as a document by itself //have to resort to convert tx_xml to string and then back to Document //for some reason DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); StringBuffer sb1 = new StringBuffer(Util.XMLDoctoString(tx_xml)); ByteArrayInputStream bis = new ByteArrayInputStream(sb1.toString().getBytes("UTF-8")); Document doc = db.parse(bis); doc.getDocumentElement().normalize(); //now that the soap response is transformed, extract the documents that were //authorized from the canonical XML AZ form NodeList nl_documents = doc.getElementsByTagName("azdecisions"); //get the NodeList under <document> HashMap hm_azdecisions = new HashMap(); ; Node n_documents = nl_documents.item(0); for (int i = 0; i < n_documents.getChildNodes().getLength(); i++) { Node n_doc = n_documents.getChildNodes().item(i); if (n_doc.getNodeType() == Node.ELEMENT_NODE) { TransformerFactory transfac = TransformerFactory.newInstance(); Transformer trans = transfac.newTransformer(); trans.setOutputProperty(OutputKeys.INDENT, "yes"); if (n_doc.getNodeName().equalsIgnoreCase("docID")) { //ok...so this doc ID was returned so we'll allow/permit this hm_azdecisions.put(n_doc.getFirstChild().getNodeValue(), "PERMIT"); } } } //for each doc ID we got in, iterate and authorize the docs that we got back.. //TODO, ofcourse we could just forego this loop //and simply iterate the hm_azdecisions hashmap to create col_resp for (int i = 0; i < v_docIDs.size(); i++) { //a doc id we got to test String in_docID = (String) v_docIDs.get(i); //if the doc exists in the set we authorized //the more i write this the more i want to just iterate the hm_azdecisions //and get it over with...i'll work on that next week if (hm_azdecisions.containsKey(in_docID)) { AuthorizationResponse ap = new AuthorizationResponse(true, in_docID); col_resp.add(ap); } } } catch (Exception bex) { logger.log(Level.SEVERE, " ERROR SUBMITTING AZ Query " + bex); } } //if the user was just authenticated //we don't have the sessionid so we'lll authorize all docs. //WEAK_AUTH flag should never get set since //we've failed the AU attempt in the BaseAuthenticationManager already else if (auth_strength.equals(BaseConstants.WEAK_AUTHENTICATION)) { logger.log(Level.FINER, "Using Weak Authentication"); if (connector.allowWeakAuth()) { col_resp = new ArrayList(); for (int i = 0; i < v_docIDs.size(); i++) { String docID = (String) v_docIDs.get(i); logger.log(Level.FINER, "Authorizing " + docID); AuthorizationResponse ap = new AuthorizationResponse(true, docID); col_resp.add(ap); } } } return col_resp; }
From source file:com.artnaseef.jmeter.report.ResultCodesStackedReport.java
/** * Extract configuration from the given report properties. * * @param prop//from ww w.j a va2 s . c o m */ protected void extractReportProperties(Properties prop) { this.detailOutputFile = prop.getProperty(ReportLauncher.PROPERTY_DETAIL_FILE_NAME); String out = prop.getProperty(ReportLauncher.PROPERTY_OUTPUT_FILENAME); if (out != null) { this.outputFile = out; } Integer size; size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_HEIGHT); if (size != null) { this.reportHeight = size; } size = (Integer) prop.get(ReportLauncher.PROPERTY_CHART_WIDTH); if (size != null) { this.reportWidth = size; } Long slotSize = (Long) prop.get(ReportLauncher.PROPERTY_TIME_SLOT_SIZE); if (slotSize != null) { this.timeSlotSize = slotSize; } Integer maxSlotsProperty = (Integer) prop.get(ReportLauncher.PROPERTY_MAX_SLOTS); if (maxSlotsProperty != null) { this.maxSlots = maxSlotsProperty; } }
From source file:cn.calm.osgi.conter.FelixOsgiHost.java
protected void replaceSystemPackages(Properties properties) { // Felix has a way to load the config file and substitution expressions // but the method does not have a way to specify the file (other than in // an env variable) // ${jre-${java.specification.version}} String systemPackages = (String) properties.get(Constants.FRAMEWORK_SYSTEMPACKAGES); String jreVersion = "jre-" + System.getProperty("java.version").substring(0, 3); systemPackages = systemPackages.replace("${jre-${java.specification.version}}", (String) properties.get(jreVersion)); properties.put(Constants.FRAMEWORK_SYSTEMPACKAGES, systemPackages); }
From source file:org.iternine.jeppetto.testsupport.JdbcDatabaseProvider.java
private ConnectionSource getConnectionSource(Properties properties, ApplicationContext applicationContext) { Map datasourceBeans = applicationContext.getBeansOfType(DataSource.class); if (datasourceBeans.size() == 0) { return null; }//from w ww.j av a2 s.com if (datasourceBeans.size() > 1) { logger.warn( "NOTE: Found more than one bean of type 'DataSource'. Selecting random from the following: {}", datasourceBeans); } DataSource dataSource = (DataSource) datasourceBeans.values().iterator().next(); return new DataSourceConnectionSource(dataSource, (String) properties.get(driverClassNameProperty)); }
From source file:com.glaf.jbpm.connection.DruidConnectionProvider.java
public void configure(Properties props) { Properties properties = new Properties(); properties.putAll(props);//from w ww . j av a 2 s. c o m for (Iterator<Object> ii = props.keySet().iterator(); ii.hasNext();) { String key = (String) ii.next(); if (key.startsWith("druid.")) { String newKey = key.substring(6); properties.put(newKey, props.get(key)); } } Properties connectionProps = ConnectionProviderFactory.getConnectionProperties(properties); log.info("Connection properties: " + PropertiesHelper.maskOut(connectionProps, Environment.PASS)); String jdbcDriverClass = properties.getProperty(Environment.DRIVER); String jdbcUrl = properties.getProperty(Environment.URL); log.info("Druid using driver: " + jdbcDriverClass + " at URL: " + jdbcUrl); autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, properties); log.info("autocommit mode: " + autocommit); if (jdbcDriverClass == null) { log.warn("No JDBC Driver class was specified by property " + Environment.DRIVER); } else { try { Class.forName(jdbcDriverClass); } catch (ClassNotFoundException cnfe) { try { ReflectUtils.instantiate(jdbcDriverClass); } catch (Exception e) { String msg = "JDBC Driver class not found: " + jdbcDriverClass; log.error(msg, e); throw new RuntimeException(msg, e); } } } try { Integer maxPoolSize = PropertiesHelper.getInteger(ConnectionConstants.PROP_MAXACTIVE, properties); Integer maxStatements = PropertiesHelper.getInteger(ConnectionConstants.PROP_MAXSTATEMENTS, properties); Integer timeBetweenEvictionRuns = PropertiesHelper .getInteger(ConnectionConstants.PROP_TIMEBETWEENEVICTIONRUNS, properties); Integer maxWait = PropertiesHelper.getInteger(ConnectionConstants.PROP_MAXWAIT, properties); String validationQuery = properties.getProperty(ConnectionConstants.PROP_VALIDATIONQUERY); if (maxPoolSize == null) { maxPoolSize = 50; } if (timeBetweenEvictionRuns == null) { timeBetweenEvictionRuns = 60; } if (maxWait == null) { maxWait = 60; } String dbUser = properties.getProperty(Environment.USER); String dbPassword = properties.getProperty(Environment.PASS); if (dbUser == null) { dbUser = ""; } if (dbPassword == null) { dbPassword = ""; } ds = new DruidDataSource(); DruidDataSourceFactory.config(ds, properties); ds.setConnectProperties(properties); ds.setDriverClassName(jdbcDriverClass); ds.setUrl(jdbcUrl); ds.setUsername(dbUser); ds.setPassword(dbPassword); ds.setInitialSize(1); ds.setMinIdle(3); ds.setMaxActive(maxPoolSize); ds.setMaxWait(maxWait * 1000L); ds.setConnectionErrorRetryAttempts(30); ds.setDefaultAutoCommit(true); ds.setTestOnReturn(false); ds.setTestOnBorrow(false); ds.setTestWhileIdle(false); if (StringUtils.isNotEmpty(validationQuery)) { log.debug("validationQuery:" + validationQuery); ds.setValidationQuery(validationQuery); ds.setTestWhileIdle(true);// ?????? } ds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRuns * 1000L);// ?? ds.setMinEvictableIdleTimeMillis(1000L * 60L * 120L);// ???? if (maxStatements != null) { ds.setPoolPreparedStatements(true); ds.setMaxOpenPreparedStatements(maxStatements); ds.setMaxPoolPreparedStatementPerConnectionSize(200); } ds.setRemoveAbandoned(false);// ? true/false ds.setRemoveAbandonedTimeout(7200);// 120 ds.setLogAbandoned(true);// ? ds.init(); } catch (Exception e) { log.error("could not instantiate Druid connection pool", e); throw new RuntimeException("Could not instantiate Druid connection pool", e); } String i = properties.getProperty(Environment.ISOLATION); if (i == null) { isolation = null; } else { isolation = new Integer(i); } }
From source file:bbdn.lti2.LTI2Servlet.java
@SuppressWarnings("unused") protected void doLaunch(HttpServletRequest request, HttpServletResponse response) { Object profile = PERSIST.get("profile"); response.setContentType("text/html"); String output = null;/*from w w w . j a va 2s .co m*/ if (profile == null) { output = "Missing profile"; } else { JSONObject providerProfile = (JSONObject) JSONValue.parse((Reader) profile); List<Properties> profileTools = new ArrayList<Properties>(); Properties info = new Properties(); String retval = LTI2Util.parseToolProfile(profileTools, info, providerProfile); String launch = null; String parameter = null; for (Properties profileTool : profileTools) { launch = (String) profileTool.get("launch"); parameter = (String) profileTool.get("parameter"); } JSONObject security_contract = (JSONObject) providerProfile.get(LTI2Constants.SECURITY_CONTRACT); String shared_secret = (String) security_contract.get(LTI2Constants.SHARED_SECRET); System.out.println("launch=" + launch); System.out.println("shared_secret=" + shared_secret); Properties ltiProps = LTI2SampleData.getLaunch(); ltiProps.setProperty(BasicLTIConstants.LTI_VERSION, BasicLTIConstants.LTI_VERSION_2); Properties lti2subst = LTI2SampleData.getSubstitution(); String settings_url = getServiceURL(request) + SVC_Settings + "/"; lti2subst.setProperty("LtiLink.custom.url", settings_url + LTI2Util.SCOPE_LtiLink + "/" + ltiProps.getProperty(BasicLTIConstants.RESOURCE_LINK_ID)); lti2subst.setProperty("ToolProxyBinding.custom.url", settings_url + LTI2Util.SCOPE_ToolProxyBinding + "/" + ltiProps.getProperty(BasicLTIConstants.CONTEXT_ID)); lti2subst.setProperty("ToolProxy.custom.url", settings_url + LTI2Util.SCOPE_ToolProxy + "/" + "42"); lti2subst.setProperty("Result.url", getServiceURL(request) + SVC_Result + "/" + ltiProps.getProperty(BasicLTIConstants.RESOURCE_LINK_ID)); // Do the substitutions Properties custom = new Properties(); LTI2Util.mergeLTI2Parameters(custom, parameter); LTI2Util.substituteCustom(custom, lti2subst); // Place the custom values into the launch LTI2Util.addCustomToLaunch(ltiProps, custom); ltiProps = BasicLTIUtil.signProperties(ltiProps, launch, "POST", "42", shared_secret, null, null, null); boolean dodebug = true; output = BasicLTIUtil.postLaunchHTML(ltiProps, launch, dodebug); } try { PrintWriter out = response.getWriter(); out.println(output); } catch (Exception e) { e.printStackTrace(); } }