private SSLConfig getSslConfig() { SSLConfig sslConfig = new SSLConfig(); sslConfig.setEnabled(true); sslConfig.setFactoryClassName(com.hazelcast.nio.ssl.BasicSSLContextFactory.class.getName()); // <properties> // <property name="keyStore">keyStore</property> // <property name="keyStorePassword">keyStorePassword</property> // <property name="keyManagerAlgorithm">SunX509</property> // <property name="trustManagerAlgorithm">SunX509</property> // <property name="protocol">TLS</property> // </properties> sslConfig.setFactoryClassName(MySSLContextFactory.class.getName()); sslConfig.getProperties().setProperty("foo", "bar"); return sslConfig; }
public HazelcastSessionDao() { log.info("Initializing Hazelcast Shiro session persistence.."); // configure Hazelcast instance final Config cfg = new Config(); cfg.setInstanceName(hcInstanceName); // group configuration cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD)); // network configuration initialization final NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(HC_PORT); // multicast final MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(false); mcCfg.setMulticastGroup(HC_MULTICAST_GROUP); mcCfg.setMulticastPort(HC_MULTICAST_PORT); // tcp final TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.addMember("127.0.0.1"); tcpCfg.setEnabled(false); // network join configuration final JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // get map map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP); log.info("Hazelcast Shiro session persistence initialized."); }
public HazelcastSessionDao() { log.info("Initializating Hazelcast Shiro session persistence.."); // configure Hazelcast instance hcInstanceName = UUID.randomUUID().toString(); Config cfg = new Config(); cfg.setInstanceName(hcInstanceName); // group configuration cfg.setGroupConfig(new GroupConfig(HC_GROUP_NAME, HC_GROUP_PASSWORD)); // network configuration initialization NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(HC_PORT); // multicast MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(true); mcCfg.setMulticastGroup(HC_MULTICAST_GROUP); mcCfg.setMulticastPort(HC_MULTICAST_PORT); // tcp TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.setEnabled(false); // network join configuration JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // get map map = Hazelcast.newHazelcastInstance(cfg).getMap(HC_MAP); log.info("Hazelcast Shiro session persistence initialized."); }
public static void main(String[] args) throws InterruptedException { final Config cfg = new Config(); cfg.setInstanceName(UUID.randomUUID().toString()); final Properties props = new Properties(); props.put("hazelcast.rest.enabled", false); props.put("hazelcast.logging.type", "slf4j"); props.put("hazelcast.connect.all.wait.seconds", 45); props.put("hazelcast.operation.call.timeout.millis", 30000); // group configuration cfg.setGroupConfig(new GroupConfig(args[0], args[1])); // network configuration initialization final NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(5701); // multicast final MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(false); // tcp final TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.addMember("127.0.0.1"); tcpCfg.setEnabled(true); // network join configuration final JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // creating cassandra client final CassandraClient dao = new CassandraClient(); dao.initialize(args[2]); final HazelcastMapStore mapStore = new HazelcastMapStore(User.class); mapStore.setDao(dao); // Adding mapstore final MapConfig mapCfg = cfg.getMapConfig("cassandra-map-store"); final MapStoreConfig mapStoreCfg = new MapStoreConfig(); mapStoreCfg.setImplementation(mapStore); mapStoreCfg.setWriteDelaySeconds(1); // to load all map at same time mapStoreCfg.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER); mapCfg.setMapStoreConfig(mapStoreCfg); cfg.addMapConfig(mapCfg); HazelcastInstance instance = Hazelcast.newHazelcastInstance(cfg); // TERM signal processing Runtime.getRuntime().addShutdownHook(new Thread(() -> { Hazelcast.shutdownAll(); })); }
public Config getConfig() { final Config cfg = new Config(); cfg.setInstanceName(instanceName); final Properties props = new Properties(); props.put("hazelcast.rest.enabled", false); props.put("hazelcast.logging.type", "slf4j"); props.put("hazelcast.connect.all.wait.seconds", 45); props.put("hazelcast.operation.call.timeout.millis", 30000); // group configuration cfg.setGroupConfig(new GroupConfig(Constants.HC_GROUP_NAME, Constants.HC_GROUP_PASSWORD)); // network configuration initialization final NetworkConfig netCfg = new NetworkConfig(); netCfg.setPortAutoIncrement(true); netCfg.setPort(Constants.HC_PORT); // multicast final MulticastConfig mcCfg = new MulticastConfig(); mcCfg.setEnabled(false); // tcp final TcpIpConfig tcpCfg = new TcpIpConfig(); tcpCfg.addMember("127.0.0.1"); tcpCfg.setEnabled(true); // network join configuration final JoinConfig joinCfg = new JoinConfig(); joinCfg.setMulticastConfig(mcCfg); joinCfg.setTcpIpConfig(tcpCfg); netCfg.setJoin(joinCfg); // ssl netCfg.setSSLConfig(new SSLConfig().setEnabled(false)); // Adding mapstore final MapConfig mapCfg = cfg.getMapConfig(storeType); final MapStoreConfig mapStoreCfg = new MapStoreConfig(); mapStoreCfg.setImplementation(store); mapStoreCfg.setWriteDelaySeconds(1); // to load all map at same time mapStoreCfg.setInitialLoadMode(MapStoreConfig.InitialLoadMode.EAGER); mapCfg.setMapStoreConfig(mapStoreCfg); cfg.addMapConfig(mapCfg); return cfg; }
public SSLConfig getSSLConfig() { return node.getConfig().getNetworkConfig().getSSLConfig(); }
public ConnectionManager(IOService ioService, ServerSocketChannel serverSocketChannel) { this.ioService = ioService; this.ipV6ScopeId = ioService.getThisAddress().getScopeId(); this.serverSocketChannel = serverSocketChannel; this.logger = ioService.getLogger(ConnectionManager.class.getName()); this.SOCKET_RECEIVE_BUFFER_SIZE = ioService.getSocketReceiveBufferSize() * KILO_BYTE; this.SOCKET_SEND_BUFFER_SIZE = ioService.getSocketSendBufferSize() * KILO_BYTE; this.SOCKET_LINGER_SECONDS = ioService.getSocketLingerSeconds(); this.SOCKET_KEEP_ALIVE = ioService.getSocketKeepAlive(); this.SOCKET_NO_DELAY = ioService.getSocketNoDelay(); int selectorCount = ioService.getSelectorThreadCount(); selectors = new InOutSelector[selectorCount]; SSLConfig sslConfig = ioService.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { socketChannelWrapperFactory = new SSLSocketChannelWrapperFactory(sslConfig); logger.log(Level.INFO, "SSL is enabled"); } else { socketChannelWrapperFactory = new DefaultSocketChannelWrapperFactory(); } SocketInterceptorConfig sic = ioService.getSocketInterceptorConfig(); if (sic != null && sic.isEnabled()) { SocketInterceptor implementation = (SocketInterceptor) sic.getImplementation(); if (implementation == null && sic.getClassName() != null) { try { implementation = (SocketInterceptor) Class.forName(sic.getClassName()).newInstance(); } catch (Throwable e) { logger.log(Level.SEVERE, "SocketInterceptor class cannot be instantiated!" + sic.getClassName(), e); } } if (implementation != null) { if (!(implementation instanceof MemberSocketInterceptor)) { logger.log(Level.SEVERE, "SocketInterceptor must be instance of " + MemberSocketInterceptor.class.getName()); implementation = null; } else { logger.log(Level.INFO, "SocketInterceptor is enabled"); } } if (implementation != null) { memberSocketInterceptor = (MemberSocketInterceptor) implementation; memberSocketInterceptor.init(sic); } else { memberSocketInterceptor = null; } } else { memberSocketInterceptor = null; } }
@Override public SSLConfig getSSLConfig() { return null; }
public ConnectionManager(IOService ioService, ServerSocketChannel serverSocketChannel) { this.ioService = ioService; this.serverSocketChannel = serverSocketChannel; this.logger = ioService.getLogger(ConnectionManager.class.getName()); this.SOCKET_RECEIVE_BUFFER_SIZE = ioService.getSocketReceiveBufferSize() * KILO_BYTE; this.SOCKET_SEND_BUFFER_SIZE = ioService.getSocketSendBufferSize() * KILO_BYTE; this.SOCKET_LINGER_SECONDS = ioService.getSocketLingerSeconds(); this.SOCKET_KEEP_ALIVE = ioService.getSocketKeepAlive(); this.SOCKET_NO_DELAY = ioService.getSocketNoDelay(); int selectorCount = ioService.getSelectorThreadCount(); selectors = new InOutSelector[selectorCount]; final Collection<Integer> ports = ioService.getOutboundPorts(); outboundPortCount = ports == null ? 0 : ports.size(); if (ports != null) { outboundPorts.addAll(ports); } SSLConfig sslConfig = ioService.getSSLConfig(); if (sslConfig != null && sslConfig.isEnabled()) { socketChannelWrapperFactory = new SSLSocketChannelWrapperFactory(sslConfig); logger.log(Level.INFO, "SSL is enabled"); } else { socketChannelWrapperFactory = new DefaultSocketChannelWrapperFactory(); } SocketInterceptorConfig sic = ioService.getSocketInterceptorConfig(); if (sic != null && sic.isEnabled()) { SocketInterceptor implementation = (SocketInterceptor) sic.getImplementation(); if (implementation == null && sic.getClassName() != null) { try { implementation = (SocketInterceptor) Class.forName(sic.getClassName()).newInstance(); } catch (Throwable e) { logger.log(Level.SEVERE, "SocketInterceptor class cannot be instantiated!" + sic.getClassName(), e); } } if (implementation != null) { if (!(implementation instanceof MemberSocketInterceptor)) { logger.log(Level.SEVERE, "SocketInterceptor must be instance of " + MemberSocketInterceptor.class.getName()); implementation = null; } else { logger.log(Level.INFO, "SocketInterceptor is enabled"); } } if (implementation != null) { memberSocketInterceptor = (MemberSocketInterceptor) implementation; memberSocketInterceptor.init(sic); } else { memberSocketInterceptor = null; } } else { memberSocketInterceptor = null; } }
SSLConfig getSSLConfig();