Example usage for java.util Hashtable put

List of usage examples for java.util Hashtable put

Introduction

In this page you can find the example usage for java.util Hashtable put.

Prototype

public synchronized V put(K key, V value) 

Source Link

Document

Maps the specified key to the specified value in this hashtable.

Usage

From source file:com.clican.pluto.cms.ui.listener.StartupListener.java

public void contextInitialized(ServletContextEvent event) {
    super.contextInitialized(event);
    try {//from   w  w w  .  j a v a 2s  .  c  o m
        Velocity.init(
                Thread.currentThread().getContextClassLoader().getResource("velocity.properties").getPath());
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    ApplicationContext ctx = null;
    JndiUtils.setJndiFactory(MockContextFactory.class.getName());
    Hashtable<String, String> ht = new Hashtable<String, String>();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, MockContextFactory.class.getName());
    try {
        ctx = (ApplicationContext) JndiUtils.lookupObject(ApplicationContext.class.getName());
        if (ctx == null) {
            log.warn("Cannot get ApplicationContext from JNDI");
        }
    } catch (Exception e) {
        log.warn("Cannot get ApplicationContext from JNDI");
    }
    if (ctx == null) {
        ctx = (new ClassPathXmlApplicationContext(new String[] { "classpath*:META-INF/ui-*.xml", }));
    }
    XmlWebApplicationContext wac = (XmlWebApplicationContext) WebApplicationContextUtils
            .getRequiredWebApplicationContext(event.getServletContext());
    wac.setParent(ctx);
    wac.refresh();
    event.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
    Constants.ctx = wac;
}

From source file:UndoableDrawingPanel2.java

public void storeState(Hashtable state) {
    state.put(POLYGON_KEY, getPolygon());
}

From source file:UndoableToggleApp4.java

public void storeState(Hashtable ht) {
    ht.put(tog, new Boolean(tog.isSelected()));
    ht.put(cb, new Boolean(cb.isSelected()));
    ht.put(radio, new Boolean(radio.isSelected()));
}

From source file:org.jasig.cas.adaptors.ldap.DigestMd5DirContextAuthenticationStrategy.java

/** {@inheritDoc} */
@SuppressWarnings(value = "unchecked")
public void setupEnvironment(final Hashtable env, final String userDn, final String password)
        throws NamingException {

    env.put(Context.SECURITY_AUTHENTICATION, DIGEST_MD5_AUTHENTICATION);
    // userDn should be a bare username for DIGEST-MD5
    env.put(Context.SECURITY_PRINCIPAL, userDn);
    env.put(Context.SECURITY_CREDENTIALS, password);

}

From source file:com.santander.serenity.security.credentials.bkstoken.internal.BKSAuthenticatorServiceComponent.java

protected void activate(ComponentContext cxt) {
    try {//from w w  w.  j  a v a 2s  .co  m
        BKSAuthenticator authenticator = new BKSAuthenticator();
        BKSAuthenticatorServiceComponent.setBundleContext(cxt.getBundleContext());
        Hashtable<String, String> props = new Hashtable<String, String>();
        props.put(CarbonConstants.AUTHENTICATOR_TYPE, authenticator.getAuthenticatorName());
        cxt.getBundleContext().registerService(CarbonServerAuthenticator.class.getName(), authenticator, props);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        // throwing so that server will not start
        throw new RuntimeException("Failed to start the BKS Authenticator Bundle" + e.getMessage(), e);
    }
    log.debug("BKS Authenticator is activated");
}

From source file:io.apiman.gateway.engine.policies.auth.LDAPIdentityValidator.java

/**
 * @see io.apiman.gateway.engine.policies.auth.IIdentityValidator#validate(java.lang.String, java.lang.String, io.apiman.gateway.engine.beans.ServiceRequest, io.apiman.gateway.engine.policy.IPolicyContext, java.lang.Object, io.apiman.gateway.engine.async.IAsyncHandler)
 *///from w  w w . j a v  a 2s .c  om
@Override
public void validate(String username, String password, ServiceRequest request, IPolicyContext context,
        LDAPIdentitySource config, IAsyncResultHandler<Boolean> handler) {
    String url = config.getUrl();
    String dn = formatDn(config.getDnPattern(), username, request);

    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); //$NON-NLS-1$
    env.put(Context.PROVIDER_URL, url);

    env.put(Context.SECURITY_AUTHENTICATION, "simple"); //$NON-NLS-1$
    env.put(Context.SECURITY_PRINCIPAL, dn);
    env.put(Context.SECURITY_CREDENTIALS, password);
    try {
        new InitialDirContext(env);
        handler.handle(AsyncResultImpl.create(Boolean.TRUE));
    } catch (AuthenticationException e) {
        handler.handle(AsyncResultImpl.create(Boolean.FALSE));
    } catch (NamingException e) {
        throw new RuntimeException(e);
    }
}

From source file:net.sf.ehcache.distribution.JNDIRMICacheManagerPeerListener.java

/**
 * Gets the initial context//from  w  ww.  j  a  v  a 2s  . c om
 *
 * @return an initial context
 * @throws NamingException if JNDI goes wrong
 */
private Context getInitialContext() throws NamingException {
    String initialContextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);

    if (initialContextFactory != null && initialContextFactory.startsWith("net.sf.ehcache")) {
        // Put Context.PROVIDER_URL so unit tests can work
        Hashtable hashTable = new Hashtable();
        hashTable.put(Context.PROVIDER_URL, "//localhost:" + port);
        return new InitialContext(hashTable);
    }
    return new InitialContext();
}

From source file:fr.aliasource.webmail.proxy.Application.java

public Object start(IApplicationContext context) throws Exception {
    logger.info("MiniG backend starting...");
    Hashtable<String, Object> settings = new Hashtable<String, Object>();
    settings.put(JettyConstants.HTTP_PORT, 8081);
    settings.put(JettyConstants.CONTEXT_PATH, "");
    settings.put(JettyConstants.CUSTOMIZER_CLASS, "org.minig.jetty.JettyPimper");

    File sslP12 = new File("/etc/minig/minig.p12");
    if (sslP12.exists()) {
        settings.put(JettyConstants.HTTPS_ENABLED, true);
        settings.put(JettyConstants.HTTPS_PORT, 8083);
        settings.put(JettyConstants.SSL_KEYSTORETYPE, "PKCS12");
        settings.put(JettyConstants.SSL_KEYSTORE, sslP12.getAbsolutePath());
        settings.put(JettyConstants.SSL_PASSWORD, "password");
        settings.put(JettyConstants.SSL_KEYPASSWORD, "password");
        settings.put(JettyConstants.SSL_PROTOCOL, "SSL");
        settings.put(JettyConstants.SSL_WANTCLIENTAUTH, false);
        settings.put(JettyConstants.SSL_NEEDCLIENTAUTH, false);
    } else {/*from  ww w  . j a va 2  s .  co  m*/
        logger.info("/etc/minig/minig.p12 not found, backend ssl support not activated");
    }

    System.setProperty("org.mortbay.jetty.Request.maxFormContentSize", "" + (20 * 1024 * 1024));

    JettyConfigurator.startServer("minig_backend", settings);

    loadBundle("org.eclipse.equinox.http.registry");

    return EXIT_OK;
}

From source file:org.code_house.openhab.cxf.internal.EndpointPublisher.java

private void start(List<Object> resources) {
    if (bus != null) {
        logger.error("Unable to start new cxf endpoint cause previous one still exists: {}", bus);
        return;/*w w  w  .j a  v a  2  s. co m*/
    }
    ExtensionManagerBus bus = new ExtensionManagerBus();
    JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
    factoryBean.setBus(bus);
    factoryBean.setAddress("/openhab");
    factoryBean.setServiceBeans(resources);
    JAASAuthenticationFilter filter = new JAASAuthenticationFilter();
    filter.setContextName("karaf");

    factoryBean.setProviders(Arrays.asList(new JacksonJsonProvider(), filter));
    factoryBean.setFeatures(Arrays.asList(new LoggingFeature()));

    factoryBean.create();

    bus.initialize();

    Hashtable<String, Object> properties = new Hashtable<>();
    properties.put(OSGIBusListener.CONTEXT_SYMBOLIC_NAME_PROPERTY, "org.code-house.openhab.cxf");
    properties.put(OSGIBusListener.CONTEXT_VERSION_PROPERTY, "0.0.0");
    properties.put(OSGIBusListener.CONTEXT_NAME_PROPERTY, "openhab");

    this.bus = bus;
    serviceRegistration = context.registerService(Bus.class, bus, properties);
}

From source file:com.vnet.demo.service.azure.servicebus.AzureServiceBusServiceFactory.java

public AzureServiceBusService create() {
    if (this.azureServiceBusService == null) {
        try {//from   w  ww.  j a v  a  2s  .co m
            PropertiesFactoryBean properties = SpringUtil.getBean(PropertiesFactoryBean.class);
            this.username = (String) properties.getObject().get("azure.servicebus.username");
            this.password = (String) properties.getObject().get("azure.servicebus.password");
            this.host = (String) properties.getObject().get("azure.servicebus.host");
            String defaultQueue = (String) properties.getObject().get("azure.servicebus.queue");

            String connectionString = "amqps://" + username + ":" + encode(password) + "@" + host;
            Hashtable<String, String> env = new Hashtable<String, String>();
            env.put(Context.INITIAL_CONTEXT_FACTORY,
                    "org.apache.qpid.amqp_1_0.jms.jndi.PropertiesFileInitialContextFactory");
            env.put("connectionfactory.ServiceBusConnectionFactory", connectionString);

            Context context = new InitialContext(env);
            ConnectionFactory connectionFactory = (ConnectionFactory) context
                    .lookup("ServiceBusConnectionFactory");
            azureServiceBusService = new AzureServiceBusService(connectionFactory, defaultQueue);
        } catch (NamingException | IOException e) {
            e.printStackTrace();
        }
        ;
    }
    return this.azureServiceBusService;
}