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 static TrustManagerFactory getTrustManagerFactory(Configuration sslConfig) throws Exception { final Configuration tdConfig = sslConfig.getChildren(TrustData.ordinal())[0]; final String trustManagerAlgo = tdConfig.getStringValue(TDManager.ordinal(), null); final String trustStoreType = tdConfig.getStringValue(TDStore.ordinal(), null); final String trustStorePassword = tdConfig.getStringValue(TDPwd.ordinal(), null); final String trustStoreFile = tdConfig.getStringValue(TDFile.ordinal(), null); logger.debug("trustManagerAlgo: {}", trustManagerAlgo); logger.debug("trustStoreType: {}", trustStoreType); logger.debug("trustStorePassword: {}", trustStorePassword); logger.debug("trustStoreFile: {}", trustStoreFile); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(trustManagerAlgo); KeyStore trustKeyStore = KeyStore.getInstance(trustStoreType); char[] trustKey = trustStorePassword.toCharArray(); trustKeyStore.load(new FileInputStream(trustStoreFile), trustKey); trustManagerFactory.init(trustKeyStore); return trustManagerFactory; }
@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 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; }
public String[] _Network_Realms_getRealmPeers(String realmName) { Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); String[] realmHosts = new String[realmEntries.length]; for(Configuration realmEntry : realmEntries) { if(realmEntry.getStringValue(RealmName.ordinal(), DEFAULT_STRING).equals(realmName)) { String realmHostsString = realmEntry.getStringValue(RealmHosts.ordinal(), DEFAULT_STRING); if(!realmHostsString.equals(DEFAULT_STRING)) { realmHosts = realmHostsString.replaceAll(" ", "").split(","); } } } return realmHosts; }
public String[] _Network_Realms_getRealmPeers(String realmName) throws MBeanException { Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); String[] realmHosts = new String[realmEntries.length]; for(Configuration realmEntry : realmEntries) { if(realmEntry.getStringValue(RealmName.ordinal(), DEFAULT_STRING).equals(realmName)) { String realmHostsString = realmEntry.getStringValue(RealmHosts.ordinal(), DEFAULT_STRING); if(!realmHostsString.equals(DEFAULT_STRING)) { realmHosts = realmHostsString.replaceAll(" ", "").split(","); } } } return realmHosts; }
@Override public String[] _Network_Realms_getRealmPeers(String realmName) throws MBeanException { Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); String[] realmHosts = new String[realmEntries.length]; for (Configuration realmEntry : realmEntries) { if (realmEntry.getStringValue(RealmName.ordinal(), DEFAULT_STRING).equals(realmName)) { String realmHostsString = realmEntry.getStringValue(RealmHosts.ordinal(), DEFAULT_STRING); if (!realmHostsString.equals(DEFAULT_STRING)) { realmHosts = realmHostsString.replaceAll(" ", "").split(","); } } } return realmHosts; }
Configuration[] apps = stack.getConfiguration().getChildren(ApplicationId.ordinal()); if (apps != null) { if (logger.isDebugEnabled()) {
private void updatePicoContainer(Configuration config, ExtensionPoint pointType, ExtensionPoint... updEntries) throws ClassNotFoundException { for (ExtensionPoint e : updEntries) { Configuration[] internalConf = config.getChildren(Extensions.ordinal()); String oldValue = internalConf[Internal.id()].getStringValue(e.ordinal(), null); String newValue = internalConf[pointType.id()].getStringValue(e.ordinal(), null); if (oldValue != null && newValue != null) { pico.removeComponent(Class.forName(oldValue)); pico.addComponent(Class.forName(newValue)); } } }
@Override public IAgentConfiguration parse(Configuration agentConfiguration) throws InternalException { if (agentConfiguration == null) { return null; } AgentConfigurationImpl conf = new AgentConfigurationImpl(); try { conf.properties = new Properties(); Configuration[] propConfs = agentConfiguration.getChildren(Properties.ordinal()); for (Configuration c : propConfs) { conf.properties.put(c.getStringValue(PropertyName.ordinal(), ""), c.getStringValue(PropertyValue.ordinal(), "")); } } catch (Exception e) { throw new InternalException(e); } return conf; }
public TransportLayerFactory(Configuration config, IMessageParser parser) throws TransportException { this.config = config; Configuration[] children = config.getChildren(Parameters.Extensions.ordinal()); AppConfiguration internalExtensions = (AppConfiguration) children[ExtensionPoint.Internal.id()]; String implName = internalExtensions.getStringValue( ExtensionPoint.InternalConnectionClass.ordinal(), ExtensionPoint.InternalConnectionClass.defValue() ); try { //TODO: this should be enough to check if class has interface!? this.connectionClass = (Class<IConnection>) forName(implName); if (!IConnection.class.isAssignableFrom(this.connectionClass)) { throw new TransportException("Specified class does not inherit IConnection interface " + this.connectionClass, TransportError.Internal); } } catch (Exception e) { throw new TransportException("Cannot prepare specified connection class " + this.connectionClass, TransportError.Internal, e); } try { //TODO: this is bad practice, IConnection is interface and this code enforces constructor type to be present! constructorIAiCL = connectionClass.getConstructor( Configuration.class, IConcurrentFactory.class, InetAddress.class, Integer.TYPE, InetAddress.class, Integer.TYPE, IConnectionListener.class, IMessageParser.class, String.class); constructorIAi = connectionClass.getConstructor( Configuration.class, IConcurrentFactory.class, InetAddress.class, Integer.TYPE, InetAddress.class, Integer.TYPE, IMessageParser.class, String.class); } catch (Exception e) { throw new TransportException("Cannot find required constructor", TransportError.Internal, e); } this.parser = parser; }
public TransportLayerFactory(Configuration conf, IConcurrentFactory concurrentFactory, IMessageParser parser, IMetaData metaData) throws TransportException { super(conf, parser); this.concurrentFactory = concurrentFactory; this.metaData = metaData; String networkGuardClassName = null; Configuration[] children = config.getChildren(org.jdiameter.client.impl.helpers.Parameters.Extensions.ordinal()); // extract network guard class name. AppConfiguration internalExtensions = (AppConfiguration) children[org.jdiameter.client.impl.helpers.ExtensionPoint.Internal.id()]; networkGuardClassName = internalExtensions.getStringValue(ExtensionPoint.InternalNetworkGuard.ordinal(), ExtensionPoint.InternalNetworkGuard.defValue()); try { // TODO: this should be enough to check if class has interface!? this.networkGuardClass = (Class<INetworkGuard>) forName(networkGuardClassName); if (!INetworkGuard.class.isAssignableFrom(this.networkGuardClass)) { throw new TransportException("Specified class does not inherit INetworkGuard interface " + this.networkGuardClass, TransportError.Internal); } } catch (Exception e) { throw new TransportException("Cannot prepare specified guard class " + this.networkGuardClass, TransportError.Internal, e); } try { // TODO: this is bad practice, IConnection is interface and this code enforces constructor type to be present! networkGuardConstructor = this.networkGuardClass.getConstructor(InetAddress[].class, Integer.TYPE, IConcurrentFactory.class, IMessageParser.class, IMetaData.class); } catch (Exception e) { throw new TransportException("Cannot find required constructor", TransportError.Internal, e); } }
public String[] _Network_Realms_getRealms() throws MBeanException { Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); String[] realmNames = new String[realmEntries.length]; for(int i = 0; i < realmEntries.length; i++) { realmNames[i] = realmEntries[i].getStringValue(RealmName.ordinal(), DEFAULT_STRING); } return realmNames; }
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 String[] _Network_Realms_getRealms() { Configuration[] realmEntries = getMutableConfiguration().getChildren(RealmTable.ordinal())[0].getChildren(RealmEntry.ordinal()); String[] realmNames = new String[realmEntries.length]; for(int i = 0; i < realmEntries.length; i++) { realmNames[i] = realmEntries[i].getStringValue(RealmName.ordinal(), DEFAULT_STRING); } return realmNames; }
/** * Create instance of class with predefined configuration * * @param config configuration of stack * @throws Exception if generated internal exception */ public AssemblerImpl(Configuration config) throws Exception { Configuration[] ext = config.getChildren(Extensions.ordinal()); for (Configuration e : ext) { String extName = e.getStringValue(ExtensionName.ordinal(), ""); // TODO: server? // Create structure of containers if (extName.equals(ExtensionPoint.Internal.name())) { fill(ExtensionPoint.Internal.getExtensionPoints(), e, true); } else if (extName.equals(ExtensionPoint.StackLayer.name())) { updatePicoContainer(config, StackLayer, InternalMetaData, InternalSessionFactory, InternalMessageParser, InternalElementParser); } else if (extName.equals(ExtensionPoint.ControllerLayer.name())) { updatePicoContainer(config, ControllerLayer, InternalPeerController, InternalPeerFsmFactory, InternalRouterEngine); } else if (extName.equals(ExtensionPoint.TransportLayer.name())) { updatePicoContainer(config, TransportLayer, InternalTransportFactory); } } }
Configuration[] peers = config.getChildren(PeerTable.ordinal());
public static SSLContext getSecureContext(Configuration sslConfig) throws Exception { // TODO: use classloader to fetch files. final String contextTransportAlgo = sslConfig.getStringValue(SDProtocol.ordinal(), null); final Configuration kdConfig = sslConfig.getChildren(KeyData.ordinal())[0]; final Configuration tdConfig = sslConfig.getChildren(TrustData.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); final String trustManagerAlgo = tdConfig.getStringValue(TDManager.ordinal(), null); final String trustStoreType = tdConfig.getStringValue(TDStore.ordinal(), null); final String trustStorePassword = tdConfig.getStringValue(TDPwd.ordinal(), null); final String trustStoreFile = tdConfig.getStringValue(TDFile.ordinal(), null); return TLSUtils.getSecureContext(contextTransportAlgo, keyManagerAlgo, keyStoreType, keyStorePassword, keyStoreFile, trustManagerAlgo, trustStoreType, trustStorePassword, trustStoreFile); }
Configuration[] peers = globalConfig.getChildren(Parameters.PeerTable.ordinal()); if (peers != null && peers.length > 0) { for (Configuration peerConfig : peers) {
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 ) {