List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.utils.SecurityUtil.java
/** * Initialize HighEncryption variable for empi and notes. *//*from w w w .ja v a 2 s . c o m*/ private void initHighEncrypt() { try { // init high encryption with notes key Hashtable<String, String> hashNotestemp = new Hashtable<String, String>(); hashNotestemp.put("A:\\I401.txt", notesKey); notesHighEnc = new HighEncryption("A:\\I401.txt", hashNotestemp); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.interseroh.report.test.security.LdapServerTest.java
@Test public void testJndiSun() throws NamingException { Hashtable<String, String> contextParams = new Hashtable<String, String>(); contextParams.put(Context.PROVIDER_URL, "ldap://ldap.xxx:389"); contextParams.put(Context.SECURITY_PRINCIPAL, USER_LDAP); contextParams.put(Context.SECURITY_CREDENTIALS, PASSWORD_LDAP); contextParams.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); DirContext dirContext = new InitialDirContext(contextParams); Attributes attributes = dirContext.getAttributes("", new String[] { "namingContexts" }); Attribute attribute = attributes.get("namingContexts"); NamingEnumeration<?> all = attribute.getAll(); while (all.hasMore()) { String next = (String) all.next(); logger.info(next);//from www.j a va2 s. co m } }
From source file:de.betterform.connector.xmlrpc.XMLRPCSubmissionHandler.java
/** * Serializes and submits the given instance data to an xmlrpc function protocol. * * @param submission the submission issuing the request. * @param instance the instance data to be serialized and submitted. * @return <code>null</code>. * @throws XFormsException if any error occurred during submission. *///from w ww.ja v a 2 s . c o m public Map submit(Submission submission, Node instance) throws XFormsException { if (!submission.getReplace().equals("none")) { throw new XFormsException("submission mode '" + submission.getReplace() + "' not supported"); } try { SerializerRequestWrapper wrapper = new SerializerRequestWrapper(new ByteArrayOutputStream()); serialize(submission, instance, wrapper); ByteArrayOutputStream stream = (ByteArrayOutputStream) wrapper.getBodyStream(); URI uri = new URI(getURI()); log.info("Getting URI: '" + uri + "'"); Vector v = parseURI(uri); String rpcURL = (String) v.get(0); String function = (String) v.get(1); Hashtable params = (Hashtable) v.get(2); params.put("doc", stream.toByteArray()); de.betterform.connector.xmlrpc.RPCClient rpc = new de.betterform.connector.xmlrpc.RPCClient(rpcURL); Hashtable result = rpc.runFunc(function, params); if (((String) result.get("status")).equals("error")) { throw new XFormsException((String) result.get("error")); } } catch (Exception e) { throw new XFormsException(e); } return null; }
From source file:com.heliumv.factory.BaseCall.java
private Context getInitialContext() throws NamingException { Context env = (Context) new InitialContext().lookup("java:comp/env"); String namingFactory = (String) env.lookup(Context.INITIAL_CONTEXT_FACTORY); String urlProvider = (String) env.lookup(Context.PROVIDER_URL); log.debug("namingFactory = {" + namingFactory + "}"); log.debug("urlProvider = {" + urlProvider + "}"); Hashtable<String, String> environment = new Hashtable<String, String>(); environment.put(Context.INITIAL_CONTEXT_FACTORY, namingFactory); environment.put(Context.PROVIDER_URL, urlProvider); return new InitialContext(environment); }
From source file:org.web4thejob.security.ADAuthenticationProvider.java
@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException { if (authentication.getName() == null || (String) authentication.getCredentials() == null) { throw new BadCredentialsException(""); }/*from w w w. jav a 2 s.c o m*/ String principal = getPrincipal(authentication.getName()); String passwd = (String) authentication.getCredentials(); LdapContext ctx = null; try { Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put(Context.INITIAL_CONTEXT_FACTORY, LdapCtxFactory.class.getCanonicalName()); env.put(Context.SECURITY_AUTHENTICATION, "Simple"); env.put(Context.SECURITY_PRINCIPAL, principal); env.put(Context.SECURITY_CREDENTIALS, passwd); env.put(Context.PROVIDER_URL, url); ctx = new InitialLdapContext(env, null); //LDAP Connection Successful UserDetails userDetails = userDetailsService.loadUserByUsername(principal); return new UsernamePasswordAuthenticationToken(userDetails, "", userDetails.getAuthorities()); } catch (NamingException nex) { throw new BadCredentialsException("LDAP authentication failed.", nex); } catch (UsernameNotFoundException e) { throw new BadCredentialsException("UserDetails did not find a valid user for name: " + principal, e); } finally { if (ctx != null) { try { ctx.close(); } catch (Exception ignore) { } } } }
From source file:com.openmeap.thinclient.RESTAppMgmtClient.java
public ConnectionOpenResponse connectionOpen(ConnectionOpenRequest request) throws WebServiceException { ConnectionOpenResponse response = null; Hashtable postData = new Hashtable(); postData.put(UrlParamConstants.ACTION, "connection-open-request"); postData.put(UrlParamConstants.DEVICE_UUID, request.getApplication().getInstallation().getUuid()); postData.put(UrlParamConstants.APP_NAME, request.getApplication().getName()); postData.put(UrlParamConstants.APP_VERSION, request.getApplication().getVersionId()); postData.put(UrlParamConstants.APPARCH_HASH, StringUtils.orEmpty(request.getApplication().getHashValue())); postData.put(UrlParamConstants.SLIC_VERSION, request.getSlic().getVersionId()); HttpResponse httpResponse = null;/*from ww w. j av a 2 s . c o m*/ InputSource responseInputSource = null; String responseText = null; try { httpResponse = requester.postData(serviceUrl, postData); if (httpResponse.getStatusCode() != 200) { throw new WebServiceException(WebServiceException.TypeEnum.CLIENT, "Posting to the service resulted in a " + httpResponse.getStatusCode() + " status code"); } responseText = Utils.readInputStream(httpResponse.getResponseBody(), "UTF-8"); } catch (Exception e) { throw new WebServiceException(WebServiceException.TypeEnum.CLIENT, StringUtils.isEmpty(e.getMessage()) ? e.getMessage() : "There's a problem connecting. Check your network or try again later", e); } // now we parse the response into a ConnectionOpenResponse object if (responseText != null) { Result result = new Result(); JSONObjectBuilder builder = new JSONObjectBuilder(); try { result = (Result) builder.fromJSON(new JSONObject(responseText), result); if (result.getError() != null) { throw new WebServiceException( WebServiceException.TypeEnum.fromValue(result.getError().getCode().value()), result.getError().getMessage()); } } catch (JSONException e) { throw new WebServiceException(WebServiceException.TypeEnum.CLIENT, "Unable to parse service response content."); } response = result.getConnectionOpenResponse(); } return response; }
From source file:com.ning.killbill.zuora.osgi.ZuoraActivator.java
private void registerServlet(final BundleContext context, final HttpServlet servlet) { final Hashtable<String, String> props = new Hashtable<String, String>(); props.put(OSGIPluginProperties.PLUGIN_NAME_PROP, PLUGIN_NAME); registrar.registerService(context, Servlet.class, servlet, props); }
From source file:org.ow2.chameleon.shell.gogo.test.converter.CollectionConverterTestCase.java
@Test public void testConvertString() throws Exception { Assert.assertEquals(converterManager.convert(Integer.class, "42"), Integer.valueOf(42), "String to Integer"); HashMap<Integer, String> map = new HashMap<Integer, String>(); map.put(42, Integer.class.getName()); Object[] in = new Object[] { map }; Field field = CollectionConverterTestCase.class.getDeclaredField("result"); ParameterizedType listType = (ParameterizedType) field.getGenericType(); ReifiedType reifiedType = new GenericType(listType); Hashtable<Float, Class<?>> hasht = new Hashtable<Float, Class<?>>(); hasht.put(42f, Integer.class); result.add(hasht);/* w w w . jav a2 s . c o m*/ Assert.assertEquals(converterManager.convert(reifiedType, in), result, "Array to List"); }
From source file:kidozen.client.crash.HttpSender.java
@Override public void send(CrashReportData report) throws ReportSenderException { try {//from w ww .j a v a2s . co m final CountDownLatch cdl = new CountDownLatch(1); IdentityManager.getInstance().GetRawToken(mApplicationKey, new ServiceEventListener() { @Override public void onFinish(ServiceEvent e) { mEvent = e; cdl.countDown(); } }); cdl.await(DEFAULT_TIMEOUT, TimeUnit.MINUTES); if (mEvent.Exception != null || mEvent.StatusCode >= HttpStatus.SC_BAD_REQUEST) throw new ReportSenderException(mEvent.Body); mToken = ((KidoZenUser) mEvent.Response).Token; String authHeaderValue = String.format("WRAP access_token=\"%s\"", mToken); Log.d(LOG_TAG, String.format("About to send log to Log V3 service: %s ", mCrashEndpoint)); JSONObject reportAsJson = report.toJSON(); String bc = new JSONArray(mBreadCrumbs).toString(); reportAsJson.put(APPLICATION_BREADCRUMB, bc); Hashtable<String, String> headers = new Hashtable<String, String>(); headers.put(Constants.AUTHORIZATION_HEADER, authHeaderValue); headers.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON); headers.put(Constants.ACCEPT, Constants.APPLICATION_JSON); mSniManager = new SNIConnectionManager(mCrashEndpoint, reportAsJson.toString(), headers, null, true); Hashtable<String, String> response = mSniManager.ExecuteHttp(KZHttpMethod.POST); String body = response.get("responseBody"); Integer statusCode = Integer.parseInt(response.get("statusCode")); if (statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) { String exceptionMessage = (body != null ? body : "Unexpected HTTP Status Code: " + statusCode); throw new Exception(exceptionMessage); } } catch (InterruptedException e) { throw new ReportSenderException("Timeout trying to send report to KidoZen services.", e); } catch (ReportSenderException e) { throw e; } catch (Exception e) { throw new ReportSenderException("Error while sending report to KidoZen services.", e); } }
From source file:edu.mayo.cts2.framework.core.config.RefreshableServerContext.java
@Override public Hashtable<String, Object> getMetadata() { Hashtable<String, Object> table = new Hashtable<String, Object>(); table.put(Constants.SERVICE_PID, ServerContext.class.getSimpleName()); return table; }