protected void loadTimeOuts(Configuration config) { CEA_TIMEOUT = config.getLongValue(CeaTimeOut.ordinal(), (Long) CeaTimeOut.defValue()); IAC_TIMEOUT = config.getLongValue(IacTimeOut.ordinal(), (Long) IacTimeOut.defValue()); DWA_TIMEOUT = config.getLongValue(DwaTimeOut.ordinal(), (Long) DwaTimeOut.defValue()); DPA_TIMEOUT = config.getLongValue(DpaTimeOut.ordinal(), (Long) DpaTimeOut.defValue()); REC_TIMEOUT = config.getLongValue(RecTimeOut.ordinal(), (Long) RecTimeOut.defValue()); }
public StatisticManagerImpl(Configuration config) { long pause = (Long) Parameters.StatisticsLoggerPause.defValue(); long delay = (Long) Parameters.StatisticsLoggerDelay.defValue(); boolean enabled = (Boolean) Parameters.StatisticsEnabled.defValue(); String activeRecords = (String) Parameters.Statistics.defValue(); Configuration[] loggerParams = config.getChildren(Parameters.Statistics.ordinal()); if (loggerParams != null && loggerParams.length > 0) { pause = loggerParams[0].getLongValue(Parameters.StatisticsLoggerPause.ordinal(), pause); delay = loggerParams[0].getLongValue(Parameters.StatisticsLoggerDelay.ordinal(), delay); enabled = loggerParams[0].getBooleanValue(Parameters.StatisticsEnabled.ordinal(), enabled); activeRecords = loggerParams[0].getStringValue(Parameters.StatisticsActiveList.ordinal(), activeRecords); } this.pause = pause; this.delay = delay; this.enabled = enabled; Set<String> enabledSet = new HashSet<String>(); if (activeRecords != null && activeRecords.length() > 0) { for (String s : activeRecords.split(",")) { enabledSet.add(s); } } this.activeRecords = Collections.unmodifiableSet(enabledSet); }
public OverloadManagerImpl(Configuration config) { Configuration[] entries = config.getChildren(OverloadMonitor.ordinal()); if (entries == null) { return; Configuration[] cAppId = e.getChildren(ApplicationId.ordinal()); for (Configuration i : cAppId) { if ( i.getLongValue(AuthApplId.ordinal(), 0) != 0 ) { appId = org.jdiameter.api.ApplicationId.createByAuthAppId( i.getLongValue(VendorId.ordinal(), 0), i.getLongValue(AuthApplId.ordinal(), 0) ); i.getLongValue(VendorId.ordinal(), 0), i.getLongValue(AcctApplId.ordinal(), 0) ); e.getIntValue(OverloadEntryIndex.ordinal(), 0), e.getDoubleValue(OverloadEntrylowThreshold.ordinal(), 0), e.getDoubleValue(OverloadEntryhighThreshold.ordinal(), 0) ); appInfo.put(appId, info);
public static Configuration getSSLConfiguration(Configuration cnf, String ref) { Configuration[] sec = cnf.getChildren(Security.ordinal());// [0].getChildren(SecurityData.ordinal()); for (Configuration i : sec) { if (i.getStringValue(SDName.ordinal(), "").equals(ref)) { return i; } } return null; } }
public TLSClientConnection(Configuration config, IConcurrentFactory concurrentFactory, InetAddress remoteAddress, int remotePort, InetAddress localAddress, int localPort, IMessageParser parser, String ref) throws Exception { String secRef = ref; if (secRef == null) { if (!config.isAttributeExist(Parameters.SecurityRef.ordinal())) { throw new IllegalArgumentException("No security_ref attribute present in local peer!"); } else { secRef = config.getStringValue(Parameters.SecurityRef.ordinal(), ""); } } this.sslConfig = TLSUtils.getSSLConfiguration(config, secRef); this.client = new TLSTransportClient(this, concurrentFactory, parser, sslConfig, new InetSocketAddress(remoteAddress, remotePort), new InetSocketAddress(localAddress, localPort)); // this.client.start(); }
@Override public boolean elementChanged(int i, Object data) { Configuration newConf = (Configuration) data; stopTimeOut = newConf.getLongValue(StopTimeOut.ordinal(), (Long) StopTimeOut.defValue()); duplicateTimer = newConf.getLongValue(DuplicateTimer.ordinal(), (Long) DuplicateTimer.defValue()); isAcceptUndefinedPeer = newConf.getBooleanValue(AcceptUndefinedPeer.ordinal(), false); return true; }
this.metaData = metaData; this.concurrentFactory = concurrentFactory; this.stopTimeOut = globalConfig.getLongValue(StopTimeOut.ordinal(), (Long) StopTimeOut.defValue()); this.sessionDatasource = stack.getAssemblerFacility().getComponentInstance(ISessionDatasource.class); Configuration[] peers = globalConfig.getChildren(Parameters.PeerTable.ordinal()); if (peers != null && peers.length > 0) { for (Configuration peerConfig : peers) { if (peerConfig.isAttributeExist(PeerName.ordinal())) { String uri = peerConfig.getStringValue(PeerName.ordinal(), null); int rating = peerConfig.getIntValue(PeerRating.ordinal(), 0); String ip = peerConfig.getStringValue(PeerIp.ordinal(), null); String portRange = peerConfig.getStringValue(PeerLocalPortRange.ordinal(), null); try {
this.network.setPeerManager(this); this.stack = stack; this.isAcceptUndefinedPeer = config.getBooleanValue(AcceptUndefinedPeer.ordinal(), false); this.duplicateProtection = config.getBooleanValue(DuplicateProtection.ordinal(), (Boolean) DuplicateProtection.defValue()); if (this.duplicateProtection) { this.duplicateTimer = config.getLongValue(DuplicateTimer.ordinal(), (Long) DuplicateTimer.defValue()); this.duplicateSize = config.getIntValue(DuplicateSize.ordinal(), (Integer) DuplicateSize.defValue());
public NetworkGuard(InetAddress[] inetAddress, int port, IConcurrentFactory concurrentFactory, IMessageParser parser, IMetaData data) throws Exception { this.parser = parser; this.localAddresses = inetAddress; this.port = port; this.concurrentFactory = concurrentFactory == null ? new DummyConcurrentFactory() : concurrentFactory; // extract sec_ref from local peer; Configuration conf = data.getConfiguration(); if (!conf.isAttributeExist(Parameters.SecurityRef.ordinal())) { throw new IllegalArgumentException("No security_ref attribute present in local peer!"); } String secRef = conf.getStringValue(Parameters.SecurityRef.ordinal(), ""); logger.debug("secRef: {}", secRef); // now need to get proper security data. this.localPeerSSLConfig = TLSUtils.getSSLConfiguration(conf, secRef); if (this.localPeerSSLConfig == null) { throw new IllegalArgumentException("No Security for security_reference '" + secRef + "'"); } this.bindDelay = data.getConfiguration().getLongValue(BindDelay.ordinal(), (Long) BindDelay.defValue()); this.binderExecutor.schedule(binderTask, bindDelay, TimeUnit.MILLISECONDS); }
Configuration[] apps = stack.getConfiguration().getChildren(ApplicationId.ordinal()); if (apps != null) { if (logger.isDebugEnabled()) { long vnd = a.getLongValue(VendorId.ordinal(), 0L); long auth = a.getLongValue(AuthApplId.ordinal(), 0L); long acc = a.getLongValue(AcctApplId.ordinal(), 0L); if (logger.isDebugEnabled()) { logger.debug("Adding app id vendor [{}] auth [{}] acc [{}]", new Object[]{vnd, auth, acc});
String name = curPeer.getStringValue(PeerName.ordinal(), ""); Boolean attemptConnect = curPeer.getBooleanValue(PeerAttemptConnection.ordinal(), false); Integer rating = curPeer.getIntValue(PeerRating.ordinal(), 0); String ip = curPeer.getStringValue(PeerIp.ordinal(), null); String portRange = curPeer.getStringValue(PeerLocalPortRange.ordinal(), ""); Integer portRangeLow = null; Integer portRangeHigh = null; portRangeHigh = Integer.parseInt(rng[1]); String securityRef = curPeer.getStringValue(SecurityRef.ordinal(), ""); network.addPeer(new NetworkPeerImpl(name, attemptConnect, rating, ip, portRangeLow, portRangeHigh, securityRef));
/** * fetch configuration for executor * @param name * @return */ private Configuration getConfigByName(String name) { if (config != null) { for (Configuration c : config) { if (c != null && c.getStringValue(Parameters.ConcurrentEntityName.ordinal(), "").equals(name)) { return c; } } } return null; }
public ParametersImpl(MutableConfiguration config) { // Generic Stack Configuration this.acceptUndefinedPeer = config.getBooleanValue(AcceptUndefinedPeer.ordinal(), true); this.duplicateProtection = config.getBooleanValue(DuplicateProtection.ordinal(), true); this.duplicateTimer = config.getLongValue(DuplicateTimer.ordinal(), 4 * 60 * 1000L); this.useUriAsFqdn = config.getBooleanValue(UseUriAsFqdn.ordinal(), false); this.queueSize = config.getIntValue(QueueSize.ordinal(), 10000); // Timeouts this.messageTimeout = config.getLongValue(MessageTimeOut.ordinal(), 60000L); this.stopTimeout = config.getLongValue(StopTimeOut.ordinal(), 10000L); this.ceaTimeout = config.getLongValue(CeaTimeOut.ordinal(), 10000L); this.iacTimeout = config.getLongValue(IacTimeOut.ordinal(), 20000L); this.dwaTimeout = config.getLongValue(DwaTimeOut.ordinal(), 10000L); this.dpaTimeout = config.getLongValue(DpaTimeOut.ordinal(), 5000L); this.recTimeout = config.getLongValue(RecTimeOut.ordinal(), 10000L); // Concurrent Entities for (Configuration concurrentEntity : config.getChildren(Concurrent.ordinal())) { String name = concurrentEntity.getStringValue(ConcurrentEntityName.ordinal(), null); String desc = concurrentEntity.getStringValue(ConcurrentEntityDescription.ordinal(), ""); int size = concurrentEntity.getIntValue(ConcurrentEntityPoolSize.ordinal(), 1); this.concurrentEntities.put(name, ConcurrentEntityImpl.createEntity(ConcurrentEntityNames.valueOf(name), desc, size)); } // Statistic Logger this.statisticLogger_Delay = config.getLongValue(StatisticsLoggerDelay.ordinal(), 5000L); this.statisticLogger_Pause = config.getLongValue(StatisticsLoggerPause.ordinal(), 5000L); }
Class assemblerClass = Class.forName(config.getStringValue(Assembler.ordinal(), (String) Assembler.defValue())); assembler = (IAssembler) assemblerClass.getConstructor(Configuration.class).newInstance(config); Configuration[] dictionaryConfigs = config.getChildren(Parameters.Dictionary.ordinal()); dictionaryClassName = dictionaryConfiguration.getStringValue(Parameters.DictionaryClass.ordinal(), (String) Parameters.DictionaryClass.defValue()); validatorEnabled = dictionaryConfiguration.getBooleanValue(Parameters.DictionaryEnabled.ordinal(), (Boolean) Parameters.DictionaryEnabled.defValue()); validatorSendLevel = ValidatorLevel.fromString(dictionaryConfiguration.getStringValue(Parameters.DictionarySendLevel.ordinal(), (String) Parameters.DictionarySendLevel.defValue())); validatorReceiveLevel = ValidatorLevel.fromString(dictionaryConfiguration.getStringValue(Parameters.DictionaryReceiveLevel.ordinal(), (String) Parameters.DictionaryReceiveLevel.defValue()));
SSLSocket sslSocket = (SSLSocket) cltFct.createSocket(this.plainSocket, null, this.plainSocket.getPort(), false); sslSocket.setEnableSessionCreation(parentConnection.getSSLConfig().getBooleanValue( SDEnableSessionCreation.ordinal(), true)); if (parentConnection.getSSLConfig().getStringValue(CipherSuites.ordinal(), null) != null) { sslSocket.setEnabledCipherSuites(parentConnection.getSSLConfig().getStringValue(CipherSuites.ordinal(), null) .split(","));
@Override public InetAddress[] getIPAddresses() { if (addresses.length == 0) { Configuration[] ipAddresses = stack.getConfiguration().getChildren(OwnIPAddresses.ordinal()); List<InetAddress> list = new ArrayList<InetAddress>(); if (ipAddresses != null) { for (Configuration address : ipAddresses) { if (address != null) { InetAddress iaddress = getAddress(address); if (iaddress != null) { list.add(iaddress); } } } } else { InetAddress address = getDefaultIpAddress(); if (address != null) { list.add(address); } } addresses = list.toArray(new InetAddress[list.size()]); } return addresses; }
public PeerFSMImpl(IContext aContext, IConcurrentFactory concurrentFactory, Configuration config, IStatisticManager statisticFactory) { this.context = aContext; this.statisticFactory = statisticFactory; this.predefSize = config.getIntValue(QueueSize.ordinal(), (Integer) QueueSize.defValue()); //PCB added logging logger.debug("Maximum FSM Queue size is [{}]", predefSize); this.eventQueue = new LinkedBlockingQueue<StateEvent>(predefSize); this.listeners = new ConcurrentLinkedQueue<StateChangeListener>(); loadTimeOuts(config); this.concurrentFactory = concurrentFactory; FSM_THREAD_COUNT = config.getIntValue(PeerFSMThreadCount.ordinal(), (Integer) PeerFSMThreadCount.defValue()); runQueueProcessing(); }
@Override protected Peer createPeer(int rating, String uri, String ip, String portRange, MetaData metaData, Configuration globalConfig, Configuration peerConfig, org.jdiameter.client.api.fsm.IFsmFactory fsmFactory, org.jdiameter.client.api.io.ITransportLayerFactory transportFactory, IStatisticManager statisticFactory, IConcurrentFactory concurrentFactory, IMessageParser parser) throws InternalException, TransportException, URISyntaxException, UnknownServiceException { logger.debug("Creating Peer for URI [{}]", uri); if (predefinedPeerTable == null) { logger.debug("Creating new empty predefined peer table"); predefinedPeerTable = new CopyOnWriteArraySet<String>(); } logger.debug("Adding URI [{}] to predefinedPeerTable", uri); predefinedPeerTable.add(new URI(uri).getFQDN()); if (peerConfig.getBooleanValue(PeerAttemptConnection.ordinal(), false)) { logger.debug("Peer at URI [{}] is configured to attempt a connection (acting as a client) and a new peer instance will be created and returned", uri); return newPeerInstance(rating, new URI(uri), ip, portRange, true, null, metaData, globalConfig, peerConfig, (IFsmFactory) fsmFactory, (ITransportLayerFactory) transportFactory, parser, statisticFactory, concurrentFactory); } else { logger.debug("Peer at URI [{}] is configured to NOT attempt a connection (i.e. acting as a server) and null will be returned", uri); return null; } }
public static KeyManagerFactory getKeyManagerFactory(Configuration sslConfig) throws Exception { final Configuration kdConfig = sslConfig.getChildren(KeyData.ordinal())[0]; final String keyManagerAlgo = kdConfig.getStringValue(KDManager.ordinal(), null); final String keyStoreType = kdConfig.getStringValue(KDStore.ordinal(), null); final String keyStorePassword = kdConfig.getStringValue(KDPwd.ordinal(), null); final String keyStoreFile = kdConfig.getStringValue(KDFile.ordinal(), null); logger.debug("keyManagerAlgo: {}", keyManagerAlgo); logger.debug("keyStoreType: {}", keyStoreType); logger.debug("keyStorePassword: {}", keyStorePassword); logger.debug("keyStoreFile: {}", keyStoreFile); KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(keyManagerAlgo); KeyStore keyStore = KeyStore.getInstance(keyStoreType); char[] key = keyStorePassword.toCharArray(); keyStore.load(new FileInputStream(keyStoreFile), key); keyManagerFactory.init(keyStore, key); return keyManagerFactory; }
String name = curPeer.getStringValue(PeerName.ordinal(), ""); Boolean attemptConnect = curPeer.getBooleanValue(PeerAttemptConnection.ordinal(), false); Integer rating = curPeer.getIntValue(PeerRating.ordinal(), 0); String ip = curPeer.getStringValue(PeerIp.ordinal(), null); String portRange = curPeer.getStringValue(PeerLocalPortRange.ordinal(), ""); Integer portRangeLow = null; Integer portRangeHigh = null; portRangeHigh = Integer.parseInt(rng[1]); String securityRef = curPeer.getStringValue(SecurityRef.ordinal(), ""); network.addPeer(new NetworkPeerImpl(name, attemptConnect, rating, ip, portRangeLow, portRangeHigh, securityRef));