List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:mypackage.FeedlyClient.java
public void addStringToPersistentDB(String key, String value) { synchronized (_persist) { Hashtable _tmp_ht = (Hashtable) _persist.getContents(codeSigningKey); _tmp_ht.put(key, value); _persist.setContents(new ControlledAccess(_tmp_ht, codeSigningKey)); PersistentObject.commit(_persist); }/*from w ww .j a v a2s .c om*/ }
From source file:com.adobe.acs.commons.wcm.notifications.impl.SystemNotificationsImpl.java
@SuppressWarnings("squid:S1149") private void registerAsEventHandler() { final Hashtable filterProps = new Hashtable<String, String>(); // Listen on Add and Remove under /etc/acs-commons/notifications filterProps.put(EventConstants.EVENT_TOPIC, new String[] { SlingConstants.TOPIC_RESOURCE_ADDED, SlingConstants.TOPIC_RESOURCE_REMOVED }); filterProps.put(EventConstants.EVENT_FILTER, "(&" + "(" + SlingConstants.PROPERTY_PATH + "=" + SystemNotificationsImpl.PATH_NOTIFICATIONS + "/*)" + ")"); this.eventHandlerRegistration = this.osgiComponentContext.getBundleContext() .registerService(EventHandler.class.getName(), this, filterProps); log.debug("Registered System Notifications as Event Handler"); }
From source file:de.betterform.connector.xmlrpc.XMLRPCSubmissionHandler.java
/** * Parses the URI into three elements.//from www. ja v a 2 s . c om * The xmlrpc URL, the function and the params * * @return a Vector */ private Vector parseURI(URI uri) { String host = uri.getHost(); int port = uri.getPort(); String path = uri.getPath(); String query = uri.getQuery(); /* Split the path up into basePath and function */ int finalSlash = path.lastIndexOf('/'); String basePath = ""; if (finalSlash > 0) { basePath = path.substring(1, finalSlash); } String function = path.substring(finalSlash + 1, path.length()); String rpcURL = "http://" + host + ":" + port + "/" + basePath; log.debug("New URL = " + rpcURL); log.debug("Function = " + function); Hashtable paramHash = new Hashtable(); if (query != null) { String[] params = query.split("&"); for (int i = 0; i < params.length; i++) { log.debug("params[" + i + "] = " + params[i]); String[] keyval = params[i].split("="); log.debug("\t" + keyval[0] + " -> " + keyval[1]); paramHash.put(keyval[0], keyval[1]); } } Vector ret = new Vector(); ret.add(rpcURL); ret.add(function); ret.add(paramHash); return ret; }
From source file:com.predic8.membrane.core.interceptor.authentication.session.LDAPUserDataProvider.java
/** * @throws NoSuchElementException if no user could be found with the given login * @throws AuthenticationException if the password does not match * @throws CommunicationException e.g. on server timeout * @throws NamingException on any other LDAP error *//* ww w . j av a 2 s . com*/ private HashMap<String, String> auth(String login, String password) throws NamingException { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); env.put("com.sun.jndi.ldap.read.timeout", timeout); env.put("com.sun.jndi.ldap.connect.timeout", connectTimeout); if (binddn != null) { env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, binddn); env.put(Context.SECURITY_CREDENTIALS, bindpw); } HashMap<String, String> userAttrs = new HashMap<String, String>(); String uid; DirContext ctx = new InitialDirContext(env); try { uid = searchUser(login, userAttrs, ctx); } finally { ctx.close(); } if (passwordAttribute != null) { if (!userAttrs.containsKey("_pass")) throw new NoSuchElementException(); String pass = userAttrs.get("_pass"); if (pass == null || !pass.startsWith("{x-plain}")) throw new NoSuchElementException(); log.debug("found password"); pass = pass.substring(9); if (!pass.equals(password)) throw new NoSuchElementException(); userAttrs.remove("_pass"); } else { env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, uid + "," + base); env.put(Context.SECURITY_CREDENTIALS, password); DirContext ctx2 = new InitialDirContext(env); try { if (readAttributesAsSelf) searchUser(login, userAttrs, ctx2); } finally { ctx2.close(); } } return userAttrs; }
From source file:com.evolveum.midpoint.pwdfilter.opendj.PasswordPusher.java
private void readConfig() throws InitializationException { String configFile = "/opt/midpoint/opendj-pwdpusher.xml"; if (System.getProperty("config") != null) { configFile = System.getProperty("config"); }/* w ww .j a v a 2s .com*/ File f = new File(configFile); if (!f.exists() || !f.canRead()) { throw new IllegalArgumentException("Config file " + configFile + " does not exist or is not readable"); } try { XMLConfiguration config = new XMLConfiguration(f); String notifierDN = "cn=" + config.getString("passwordpusher.statusNotifierName") + ",cn=Account Status Notification Handlers"; String ldapURL = config.getString("passwordpusher.ldapServerURL"); boolean ldapSSL = config.getBoolean("passwordpusher.ldapServerSSL"); String ldapUsername = config.getString("passwordpusher.ldapServerUsername"); String ldapPassword = config.getString("passwordpusher.ldapServerPassword"); Hashtable<Object, Object> env = new Hashtable<Object, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, ldapURL + "/cn=config"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, ldapUsername); env.put(Context.SECURITY_CREDENTIALS, ldapPassword); if (ldapSSL) { env.put(Context.SECURITY_PROTOCOL, "ssl"); } try { DirContext context = new InitialDirContext(env); Attributes attr = context.getAttributes(notifierDN); this.endPoint = attr.get("ds-cfg-referrals-url").get(0).toString(); this.username = attr.get("ds-cfg-midpoint-username").get(0).toString(); this.password = attr.get("ds-cfg-midpoint-password").get(0).toString(); this.pwdChangeDirectory = attr.get("ds-cfg-midpoint-passwordcachedir").get(0).toString(); } catch (NamingException ne) { throw new InitializationException( ERR_MIDPOINT_PWDSYNC_READING_CONFIG_FROM_LDAP.get(ne.getMessage()), ne); } } catch (ConfigurationException ce) { throw new InitializationException(ERR_MIDPOINT_PWDSYNC_PARSING_XML_CONFIG.get(ce.getMessage()), ce); } }
From source file:com.github.r351574nc3.amex.assignment1.csv.DefaultInterpreter.java
/** * Convert records to {@link TestData}./* ww w . j ava 2 s . c o m*/ * * @return {@link Hashtable} instance which makes record lookup by name much easier. Records that belong to a given name are indexed * within the {@link Hashtable} instance. In case there is more than one instance, the object in the {@link Hashtable} is * a {@link LinkedList} which can be quickly iterated */ public Hashtable interpret(final File input) throws IOException { final CSVParser parser = CSVParser.parse(input, Charset.defaultCharset(), CSVFormat.RFC4180.withDelimiter('|')); // Using a {@link Hashtable with the name field on the CSV record as the key. A lower load factor is used to give more // priority to the time cost for looking up values. final Hashtable<String, LinkedList<TestData>> index = new Hashtable<String, LinkedList<TestData>>(2, 0.5f); for (final CSVRecord record : parser) { final EmailNotificationTestData data = toTestData(record); LinkedList<TestData> data_ls = index.get(data.getName()); if (data_ls == null) { data_ls = new LinkedList<TestData>(); index.put(data.getName(), data_ls); } data_ls.add(data); } return index; }
From source file:com.zotoh.maedr.device.JmsIO.java
private void inizConn() throws Exception { Hashtable<String, String> vars = new Hashtable<String, String>(); Context ctx;// ww w . j ava 2 s. c om Object obj; if (!isEmpty(_ctxFac)) { vars.put(Context.INITIAL_CONTEXT_FACTORY, _ctxFac); } if (!isEmpty(_url)) { vars.put(Context.PROVIDER_URL, _url); } if (!isEmpty(_JNDIPwd)) { vars.put("jndi.password", _JNDIPwd); } if (!isEmpty(_JNDIUser)) { vars.put("jndi.user", _JNDIUser); } ctx = new InitialContext(vars); obj = ctx.lookup(_connFac); if (obj instanceof QueueConnectionFactory) { inizQueue(ctx, obj); } else if (obj instanceof TopicConnectionFactory) { inizTopic(ctx, obj); } else if (obj instanceof ConnectionFactory) { inizFac(ctx, obj); } else { throw new Exception("JmsIO: unsupported JMS Connection Factory"); } if (_conn != null) { _conn.start(); } }
From source file:io.apiman.gateway.engine.policies.BasicAuthLDAPTest.java
private DirContext createContext() throws NamingException { // Create a environment container Hashtable<Object, Object> env = new Hashtable<>(); String url = "ldap://" + LDAP_SERVER + ":" + ldapServer.getPort(); // Create a new context pointing to the partition env.put(Context.PROVIDER_URL, url); env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); env.put(Context.SECURITY_CREDENTIALS, "secret"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); // Let's open a connection on this partition InitialContext initialContext = new InitialContext(env); // We should be able to read it DirContext appRoot = (DirContext) initialContext.lookup(""); Assert.assertNotNull(appRoot);// w w w . j av a 2s .c o m return appRoot; }
From source file:de.fzi.ALERT.actor.MessageObserver.PatternObserver.JMSPatternParser.java
public Pattern xpathParsePatternEvent(String msgString) { System.out.println("pattern event:"); String s2 = msgString.replaceAll("[\n\r]", ""); System.out.println("new message: " + s2); System.out.println(msgString); Pattern pattern = new Pattern(); StringReader in = new StringReader(s2); try {/*from w ww . j av a2 s .c o m*/ Document doc = this.builder.build(in); Element root = doc.getRootElement(); String wsntNsPrefix; String patternNsPrefix; String alertNsPrefix; String patternEventName = null; String patternId = null; String cepatName = null; String cepatDescription = null; Hashtable<String, String> nstable = new Hashtable<String, String>(); String rootprefix = root.getNamespacePrefix(); if (rootprefix != null) nstable.put(root.getNamespaceURI(), rootprefix); List otherNs = root.getAdditionalNamespaces(); if (otherNs != null) { for (int i = 0; i < otherNs.size(); i++) { Namespace ns = (Namespace) otherNs.get(i); nstable.put(ns.getURI(), ns.getPrefix()); } } wsntNsPrefix = nstable.get(wsntNsURI); if (wsntNsPrefix != null) { XPath xpath = XPath.newInstance("//" + wsntNsPrefix + ":Message/*"); xpath.addNamespace(wsntNsPrefix, wsntNsURI); Object result = xpath.selectSingleNode(doc); if (result != null) { Element eventElement = (Element) result; String eventElementPrefix = eventElement.getNamespacePrefix(); if (eventElementPrefix != null) nstable.put(eventElement.getNamespaceURI(), eventElementPrefix); List atrs = eventElement.getAdditionalNamespaces(); for (int j = 0; j < atrs.size(); j++) { Namespace ans = (Namespace) atrs.get(j); nstable.put(ans.getURI(), ans.getPrefix()); } patternNsPrefix = nstable.get(patternNsURI); alertNsPrefix = nstable.get(alertNsURI); if (alertNsPrefix != null && patternNsPrefix != null) { xpath.addNamespace(alertNsPrefix, alertNsURI); xpath.addNamespace(patternNsPrefix, patternNsURI); Object eventNameElementObj = XPath.selectSingleNode(eventElement, "//" + alertNsPrefix + ":eventName/text()"); if (eventNameElementObj != null) { Text eventNameElement = (Text) eventNameElementObj; patternEventName = eventNameElement.getText(); } Object patternIdElementObj = XPath.selectSingleNode(eventElement, "//" + patternNsPrefix + ":cepatUID"); if (patternIdElementObj != null) { Element patternIdElement = (Element) patternIdElementObj; patternId = patternIdElement.getAttributeValue("value"); } Object cepatNameElementObj = XPath.selectSingleNode(eventElement, "//" + patternNsPrefix + ":cepatName"); if (cepatNameElementObj != null) { Element cepatNameElement = (Element) cepatNameElementObj; cepatName = cepatNameElement.getAttributeValue("value"); } Object cepatDescriptionElementObj = XPath.selectSingleNode(eventElement, "//" + patternNsPrefix + ":cepatDescription"); if (cepatDescriptionElementObj != null) { Element cepatDescriptionElement = (Element) cepatDescriptionElementObj; cepatDescription = cepatDescriptionElement.getAttributeValue("value"); } if (patternEventName != null) { if (patternEventName.equals(PATTERN_CREATED)) pattern.setStatus(0); else if (patternEventName.equals(PATTERN_MODIFIED)) pattern.setStatus(1); else if (patternEventName.equals(PATTERN_DELETED)) pattern.setStatus(2); else { System.out.println("The action type of the Pattern Message is wrong!"); } System.out.println( "pattern event type: " + patternEventName + " status:" + pattern.getStatus()); pattern.setPatternID(patternId); pattern.setPatternName(cepatName); pattern.setDescription(cepatDescription); } } } } } catch (JDOMException e) { System.out.println(msgString + " is not valid."); System.out.println(e.getMessage()); } catch (Exception e) { // TODO Auto-generated catch block System.out.println("Could not check " + msgString); System.out.println(" because " + e.getMessage()); } return pattern; }
From source file:com.ibm.soatf.component.jms.JmsComponent.java
private InitialContext getInitialContext(String providerUrl, String userName, String password) throws NamingException { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL, providerUrl); ht.put(Context.SECURITY_PRINCIPAL, userName); ht.put(Context.SECURITY_CREDENTIALS, password); return new InitialContext(ht); }