List of usage examples for org.apache.commons.configuration Configuration getInt
int getInt(String key);
From source file:es.udc.gii.common.eaf.algorithm.parallel.migration.MigrationOperator.java
/** Configures this operator.<p> * * Configuration example://from w w w .j a va2s . c om * * <pre> * <Operator> * <Class>...parallel.migration.MigrationOperator</Class> * * <MigrationFrequency>2</MigrationFrequency> * * <CullingStrategy> * <Class>...</Class> * ... * </CullingStrategy> * * <SelectionStrategy> * <Class>...</Class> * ... * </SelectionStrategy> * * <AcceptancePolicy> * <Class>...</Class> * ... * </AcceptancePolicy> * * <Topology> * <Class>...</Class> * ... * </Topology> * * <Synchronized/> * </Operator> * </pre> * * <p>Migration will be performed every 2 generations and, before receiving, * all nodes are synchronized. If no synchronization is needed, simply remove * the {@code <Synchronized/>} tag. * * @param conf Configuration. */ @Override public void configure(Configuration conf) { try { MigrationTopology mt = null; if (conf.containsKey("Topology.Class")) { mt = (MigrationTopology) Class.forName(conf.getString("Topology.Class")).newInstance(); mt.configure(conf.subset("Topology")); } else { (new ConfWarning("MigrationOperator.Topology.Class", "FullConnectedMigrationTopology")).warn(); mt = new FullConnectedMigrationTopology(); } setMigrationTopology(mt); if (mt.isConnected()) { int migFreq = 1; MigCullingStrategy mCS = null; MigSelectionStrategy mSS = null; MigAcceptancePolicy mAP = null; if (conf.containsKey("MigrationFrequency")) { migFreq = conf.getInt("MigrationFrequency"); } else { (new ConfWarning("MigrationOperator.MigrationFrequency", migFreq)).warn(); } setMigrationFrequecy(migFreq); if (conf.containsKey("CullingStrategy.Class")) { mCS = (MigCullingStrategy) Class.forName(conf.getString("CullingStrategy.Class")).newInstance(); mCS.configure(conf.subset("CullingStrategy")); } else { mCS = new WorstCull(); (new ConfWarning("MigrationOperator.CullingStrategy.Class", "WorstCull")).warn(); } setMigCullingStrategy(mCS); if (conf.containsKey("SelectionStrategy.Class")) { mSS = (MigSelectionStrategy) Class.forName(conf.getString("SelectionStrategy.Class")) .newInstance(); mSS.configure(conf.subset("SelectionStrategy")); } else { (new ConfWarning("MigrationOperator.SelectionStrategy." + "Class", "BestMigration")).warn(); mSS = new BestMigration(); } setMigSelectionStrategy(mSS); if (conf.containsKey("AcceptancePolicy.Class")) { mAP = (MigAcceptancePolicy) Class.forName(conf.getString("AcceptancePolicy.Class")) .newInstance(); mAP.configure(conf.subset("AcceptancePolicy")); } else { (new ConfWarning("MigrationOperator.AcceptancePolicy." + "Class", "GenerationBasedAcceptance")) .warn(); mAP = new GenerationBasedAcceptance(); } setMigAcceptancePolicy(mAP); setSynchronized(conf.containsKey("Synchronized")); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:edu.hawaii.soest.pacioos.text.SimpleTextSource.java
/** * Constructor: create an instance of the simple SimpleTextSource * @param xmlConfig /* ww w .j a v a 2s . c om*/ */ public SimpleTextSource(XMLConfiguration xmlConfig) throws ConfigurationException { this.xmlConfig = xmlConfig; // Pull the general configuration from the properties file Configuration config = new PropertiesConfiguration("textsource.properties"); this.archiveMode = config.getString("textsource.archive_mode"); this.rbnbChannelName = config.getString("textsource.rbnb_channel"); this.serverName = config.getString("textsource.server_name "); this.delimiter = config.getString("textsource.delimiter"); this.pollInterval = config.getInt("textsource.poll_interval"); this.retryInterval = config.getInt("textsource.retry_interval"); this.defaultDateFormat = new SimpleDateFormat(config.getString("textsource.default_date_format")); // parse the record delimiter from the config file // set the XML configuration in the simple text source for later use this.setConfiguration(xmlConfig); // set the common configuration fields String connectionType = this.xmlConfig.getString("connectionType"); this.setConnectionType(connectionType); String channelName = xmlConfig.getString("channelName"); this.setChannelName(channelName); String identifier = xmlConfig.getString("identifier"); this.setIdentifier(identifier); String rbnbName = xmlConfig.getString("rbnbName"); this.setRBNBClientName(rbnbName); String rbnbServer = xmlConfig.getString("rbnbServer"); this.setServerName(rbnbServer); int rbnbPort = xmlConfig.getInt("rbnbPort"); this.setServerPort(rbnbPort); int archiveMemory = xmlConfig.getInt("archiveMemory"); this.setCacheSize(archiveMemory); int archiveSize = xmlConfig.getInt("archiveSize"); this.setArchiveSize(archiveSize); // set the default channel information Object channels = xmlConfig.getList("channels.channel.name"); int totalChannels = 1; if (channels instanceof Collection) { totalChannels = ((Collection<?>) channels).size(); } // find the default channel with the ASCII data string for (int i = 0; i < totalChannels; i++) { boolean isDefaultChannel = xmlConfig.getBoolean("channels.channel(" + i + ")[@default]"); if (isDefaultChannel) { String name = xmlConfig.getString("channels.channel(" + i + ").name"); this.setChannelName(name); String dataPattern = xmlConfig.getString("channels.channel(" + i + ").dataPattern"); this.setPattern(dataPattern); String fieldDelimiter = xmlConfig.getString("channels.channel(" + i + ").fieldDelimiter"); // handle hex-encoded field delimiters if (fieldDelimiter.startsWith("0x") || fieldDelimiter.startsWith("\\x")) { Byte delimBytes = Byte.parseByte(fieldDelimiter.substring(2), 16); byte[] delimAsByteArray = new byte[] { delimBytes.byteValue() }; String delim = null; try { delim = new String(delimAsByteArray, 0, delimAsByteArray.length, "ASCII"); } catch (UnsupportedEncodingException e) { throw new ConfigurationException("There was an error parsing the field delimiter." + " The message was: " + e.getMessage()); } this.setDelimiter(delim); } else { this.setDelimiter(fieldDelimiter); } String[] recordDelimiters = xmlConfig .getStringArray("channels.channel(" + i + ").recordDelimiters"); this.setRecordDelimiters(recordDelimiters); // set the date formats list List<String> dateFormats = (List<String>) xmlConfig .getList("channels.channel(" + i + ").dateFormats.dateFormat"); if (dateFormats.size() != 0) { for (String dateFormat : dateFormats) { // validate the date format string try { SimpleDateFormat format = new SimpleDateFormat(dateFormat); } catch (IllegalFormatException ife) { String msg = "There was an error parsing the date format " + dateFormat + ". The message was: " + ife.getMessage(); if (log.isDebugEnabled()) { ife.printStackTrace(); } throw new ConfigurationException(msg); } } setDateFormats(dateFormats); } else { log.warn("No date formats have been configured for this instrument."); } // set the date fields list List<String> dateFieldList = xmlConfig.getList("channels.channel(" + i + ").dateFields.dateField"); List<Integer> dateFields = new ArrayList<Integer>(); if (dateFieldList.size() != 0) { for (String dateField : dateFieldList) { try { Integer newDateField = new Integer(dateField); dateFields.add(newDateField); } catch (NumberFormatException e) { String msg = "There was an error parsing the dateFields. The message was: " + e.getMessage(); throw new ConfigurationException(msg); } } setDateFields(dateFields); } else { log.warn("No date fields have been configured for this instrument."); } String timeZone = xmlConfig.getString("channels.channel(" + i + ").timeZone"); this.setTimezone(timeZone); break; } } // Check the record delimiters length and set the first and optionally second delim characters if (this.recordDelimiters.length == 1) { this.firstDelimiterByte = (byte) Integer.decode(this.recordDelimiters[0]).byteValue(); } else if (this.recordDelimiters.length == 2) { this.firstDelimiterByte = (byte) Integer.decode(this.recordDelimiters[0]).byteValue(); this.secondDelimiterByte = (byte) Integer.decode(this.recordDelimiters[1]).byteValue(); } else { throw new ConfigurationException("The recordDelimiter must be one or two characters, " + "separated by a pipe symbol (|) if there is more than one delimiter character."); } byte[] delimiters = new byte[] {}; }
From source file:com.springrts.springls.Client.java
public void sendWelcomeMessage() { Configuration conf = context.getService(Configuration.class); // the welcome messages command-name is hardcoded to TASSERVER // XXX maybe change TASSERVER to WELCOME or the like -> protocol change sendLine(String.format("TASSERVER %s %s %d %d", conf.getString(ServerConfiguration.LOBBY_PROTOCOL_VERSION), conf.getString(ServerConfiguration.ENGINE_VERSION), conf.getInt(ServerConfiguration.NAT_PORT), conf.getBoolean(ServerConfiguration.LAN_MODE) ? 1 : 0)); }
From source file:com.boozallen.cognition.ingest.storm.topology.ConfigurableIngestTopology.java
protected void configureStorm(Configuration conf, Config stormConf) throws IllegalAccessException { stormConf.registerSerialization(LogRecord.class); //stormConf.registerSerialization(Entity.class); stormConf.registerMetricsConsumer(LoggingMetricsConsumer.class); for (Iterator<String> iter = conf.getKeys(); iter.hasNext();) { String key = iter.next(); String keyString = key.toString(); String cleanedKey = keyString.replaceAll("\\.\\.", "."); String schemaFieldName = cleanedKey.replaceAll("\\.", "_").toUpperCase() + "_SCHEMA"; Field field = FieldUtils.getField(Config.class, schemaFieldName); Object fieldObject = field.get(null); if (fieldObject == Boolean.class) stormConf.put(cleanedKey, conf.getBoolean(keyString)); else if (fieldObject == String.class) stormConf.put(cleanedKey, conf.getString(keyString)); else if (fieldObject == ConfigValidation.DoubleValidator) stormConf.put(cleanedKey, conf.getDouble(keyString)); else if (fieldObject == ConfigValidation.IntegerValidator) stormConf.put(cleanedKey, conf.getInt(keyString)); else if (fieldObject == ConfigValidation.PowerOf2Validator) stormConf.put(cleanedKey, conf.getLong(keyString)); else if (fieldObject == ConfigValidation.StringOrStringListValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else if (fieldObject == ConfigValidation.StringsValidator) stormConf.put(cleanedKey, Arrays.asList(conf.getStringArray(keyString))); else {//from w w w . j av a 2 s .c o m logger.error( "{} cannot be configured from XML. Consider configuring in navie storm configuration."); throw new UnsupportedOperationException(cleanedKey + " cannot be configured from XML"); } } }
From source file:edu.emory.library.tast.images.admin.ImagesBean.java
public String saveImage() { Session sess = null;//from w ww. ja v a 2s .c om Transaction transaction = null; try { // open db sess = HibernateConn.getSession(); transaction = sess.beginTransaction(); // load image Image image = null; if (selectedImageId != null) { image = Image.loadById(Integer.parseInt(selectedImageId), sess); } else { image = new Image(); } // basic image metadata image.setTitle(imageTitle); image.setSource(imageSource); image.setCreator(imageCreator); image.setReferences(imageReferences); image.setEmoryLocation(imageEmoryLocation); image.setExternalId(imageExternalId); // we will use it often Configuration appConf = AppConfig.getConfiguration(); // image properties image.setWidth(imageWidth); image.setHeight(imageHeight); image.setSize(imageSize); image.setFileName(imageFileName); image.setMimeType(imageMimeType); // title String titleLocal = checkTextField(image.getTitle(), "title", appConf.getInt(AppConfig.IMAGES_TITLE_MAXLEN), false); image.setTitle(titleLocal); // description image.setDescription(imageDescription); // category ImageCategory cat = ImageCategory.loadById(sess, imageCategoryId); image.setCategory(cat); // check source String sourceLocal = checkTextField(image.getSource(), "source", appConf.getInt(AppConfig.IMAGES_SOURCE_MAXLEN), true); image.setSource(sourceLocal); // date image.setDate(imageDate); // check creator String creatorLocal = checkTextField(image.getCreator(), "creator", appConf.getInt(AppConfig.IMAGES_CREATOR_MAXLEN), true); image.setCreator(creatorLocal); // language image.setLanguage(imageLanguage); // comments image.setComments(imageComments); // check references String referencesLocal = checkTextField(image.getReferences(), "references", appConf.getInt(AppConfig.IMAGES_REFERENCES_MAXLEN), true); image.setReferences(referencesLocal); // is at Emory image.setEmory(imageEmory); // check emory location String emoryLocationLocal = checkTextField(image.getEmoryLocation(), "Emory location", appConf.getInt(AppConfig.IMAGES_EMORYLOCATION_MAXLEN), true); image.setEmoryLocation(emoryLocationLocal); // authorization status image.setAuthorizationStatus(imageAuthorizationStatus); // image status image.setImageStatus(imageImageStatus); // image ready to go image.setReadyToGo(imageReadyToGo); // links to regions (not shown now) Set imageRegions = new HashSet(); image.setRegions(imageRegions); for (int i = 0; i < selectedRegionsIds.length; i++) { int regionId = Integer.parseInt(selectedRegionsIds[i]); Region dbRegion = Region.loadById(sess, regionId); imageRegions.add(dbRegion); } // links to ports (not shown now) Set imagePorts = new HashSet(); image.setPorts(imagePorts); for (int i = 0; i < selectedPortsIds.length; i++) { int portId = Integer.parseInt(selectedPortsIds[i]); Port dbPort = Port.loadById(sess, portId); imagePorts.add(dbPort); } // links to voyages Integer[] newVoyageIds; try { newVoyageIds = StringUtils .parseIntegerArray(StringUtils.splitByLinesAndRemoveEmpty(imageVoyageIds)); } catch (NumberFormatException nfe) { throw new SaveImageException("All linked voyage IDs have to be integers."); } Set voyageIds = image.getVoyageIds(); voyageIds.clear(); Collections.addAll(voyageIds, newVoyageIds); // save sess.saveOrUpdate(image); // commit transaction.commit(); sess.close(); return "list"; } catch (SaveImageException se) { if (transaction != null) transaction.rollback(); if (sess != null) sess.close(); setErrorText(se.getMessage()); return null; } catch (DataException de) { if (transaction != null) transaction.rollback(); if (sess != null) sess.close(); setErrorText("Internal problem with database. Sorry for the inconvenience."); return null; } }
From source file:com.bigdata.blueprints.BigdataGraphConfiguration.java
protected BigdataGraph configure(final GraphConfigurationContext context) throws Exception { final Configuration config = context.getProperties(); if (!config.containsKey(Options.TYPE)) { throw new GraphConfigurationException("missing required parameter: " + Options.TYPE); }/*from w w w .ja v a 2s .co m*/ final String type = config.getString(Options.TYPE).toLowerCase(); if (Options.TYPE_EMBEDDED.equals(type)) { if (config.containsKey(Options.FILE)) { final String journal = config.getString(Options.FILE); return BigdataGraphFactory.open(journal, true); } else { return BigdataGraphFactory.create(); } } else if (Options.TYPE_REMOTE.equals(type)) { if (config.containsKey(Options.SPARQL_ENDPOINT_URL)) { final String sparqlEndpointURL = config.getString(Options.SPARQL_ENDPOINT_URL); return BigdataGraphFactory.connect(sparqlEndpointURL); } if (!config.containsKey(Options.HOST)) { throw new GraphConfigurationException("missing required parameter: " + Options.HOST); } if (!config.containsKey(Options.PORT)) { throw new GraphConfigurationException("missing required parameter: " + Options.PORT); } final String host = config.getString(Options.HOST); final int port = config.getInt(Options.PORT); return BigdataGraphFactory.connect(host, port); } else { throw new GraphConfigurationException("unrecognized value for " + Options.TYPE + ": " + type); } }
From source file:com.vvote.verifier.component.votePacking.VotePackingConfig.java
/** * Constructor for a VotePackingConfig object from a String * /*from ww w.j a va2 s .co m*/ * @param configLocation * The filename or filepath of the config in string format * @throws ConfigException */ public VotePackingConfig(String configLocation) throws ConfigException { logger.debug("Reading in Vote Packing specific configuration data"); if (configLocation == null) { logger.error("Cannot successfully create a VotePackingConfig"); throw new ConfigException("Cannot successfully create a VotePackingConfig"); } if (configLocation.length() == 0) { logger.error("Cannot successfully create a VotePackingConfig"); throw new ConfigException("Cannot successfully create a VotePackingConfig"); } try { Configuration config = new PropertiesConfiguration(configLocation); if (config.containsKey(ConfigFileConstants.VotePackingConfig.CURVE)) { this.curve = config.getString(ConfigFileConstants.VotePackingConfig.CURVE); } else { logger.error( "Cannot successfully create a VotePackingConfig - must contain the name of the curve used"); throw new ConfigException( "Cannot successfully create a VotePackingConfig - must contain the name of the curve used"); } if (config.containsKey(ConfigFileConstants.VotePackingConfig.PADDING_FILE)) { this.paddingFile = config.getString(ConfigFileConstants.VotePackingConfig.PADDING_FILE); } else { logger.error( "Cannot successfully create a VotePackingConfig - must contain the name of the padding file"); throw new ConfigException( "Cannot successfully create a VotePackingConfig - must contain the name of the padding file"); } if (config.containsKey(ConfigFileConstants.VotePackingConfig.TABLE_LA_LINE_LENGTH)) { this.laLineLength = config.getInt(ConfigFileConstants.VotePackingConfig.TABLE_LA_LINE_LENGTH); } else { this.laLineLength = -1; } if (config.containsKey(ConfigFileConstants.VotePackingConfig.TABLE_LA_PACKING)) { this.laPacking = config.getInt(ConfigFileConstants.VotePackingConfig.TABLE_LA_PACKING); } else { this.laPacking = -1; } if (config.containsKey(ConfigFileConstants.VotePackingConfig.TABLE_BTL_LINE_LENGTH)) { this.lcBTLLineLength = config.getInt(ConfigFileConstants.VotePackingConfig.TABLE_BTL_LINE_LENGTH); } else { this.lcBTLLineLength = -1; } if (config.containsKey(ConfigFileConstants.VotePackingConfig.TABLE_BTL_PACKING)) { this.lcBTLPacking = config.getInt(ConfigFileConstants.VotePackingConfig.TABLE_BTL_PACKING); } else { this.lcBTLPacking = -1; } if (config.containsKey(ConfigFileConstants.VotePackingConfig.CANDIDATE_TABLES)) { this.candidateTablesFolder = config .getString(ConfigFileConstants.VotePackingConfig.CANDIDATE_TABLES); } else { logger.error( "Cannot successfully create a VotePackingConfig - must contain the name of the candidates table"); throw new ConfigException( "Cannot successfully create a VotePackingConfig - must contain the candidates table"); } this.useDirect = new HashMap<RaceType, Boolean>(); this.useDirect.put(RaceType.LA, false); this.useDirect.put(RaceType.LC_ATL, false); this.useDirect.put(RaceType.LC_BTL, false); if (config.containsKey(ConfigFileConstants.VotePackingConfig.USE_DIRECT)) { String[] directlyUsed = config.getStringArray(ConfigFileConstants.VotePackingConfig.USE_DIRECT); for (String race : directlyUsed) { RaceType raceType = RaceType.fromString(race); if (raceType != null) { this.useDirect.remove(raceType); this.useDirect.put(raceType, true); } else { logger.error( "Cannot successfully create a VotePackingConfig - misformed use direct race type"); throw new ConfigException( "Cannot successfully create a VotePackingConfig - misformed use direct race type"); } } } } catch (ConfigurationException e) { logger.error("Cannot successfully create a VotePackingConfig", e); throw new ConfigException("Cannot successfully create a VotePackingConfig", e); } }
From source file:es.udc.gii.common.eaf.algorithm.CMAEvolutionaryAlgorithm.java
@Override public void configure(Configuration conf) { super.configure(conf); try {//from www . ja va2 s. com if (conf.containsKey("InitialX")) { double x = conf.getDouble("InitialX"); this.xMean = new double[] { x }; } else { this.xMean = new double[] { 0.0 }; ConfWarning w = new ConfWarning("EvolutionaryAlgorithm.InitialX", 0.0); w.warn(); } if (conf.containsKey("TypicalX")) { double x = conf.getDouble("TypicalX"); this.typicalX = new double[] { x }; } else { this.typicalX = null; ConfWarning w = new ConfWarning("EvolutionaryAlgorithm.TypicalX", 0.0); w.warn(); } if (conf.containsKey("InitialStandardDeviation")) { this.startsigma = new double[] { conf.getDouble("InitialStandardDeviation") }; } else { this.startsigma = new double[] { 1.0 }; ConfWarning w = new ConfWarning("EvolutionaryAlgorithm.InitialStandardDeviation", 1.0); w.warn(); } if (conf.containsKey("Mu")) { this.mu = conf.getInt("Mu"); } else { this.mu = -1; ConfWarning w = new ConfWarning("EvolutionaryAlgorithm.Mu", this.mu); w.warn(); } if (conf.containsKey("RecombinationType")) { this.recombinationType = (RecombinationType) Class .forName(conf.getString("RecombinationType.Class")).newInstance(); this.recombinationType.configure(conf.subset("RecombinationType")); } else { ConfWarning w = new ConfWarning("EvolutionaryAlgorithm.RecombinationType", this.recombinationType.toString()); w.warn(); } if (conf.containsKey("Cs")) { this.cs = conf.getDouble("Cs"); } else { this.cs = -1; ConfWarning w = new ConfWarning("CMAEvolutionaryAlgorithm.Cs", this.cs); w.warn(); } if (conf.containsKey("Damps")) { this.damps = conf.getDouble("Damps"); } else { this.damps = -1; ConfWarning w = new ConfWarning("CMAEvolutionaryAlgorithm.Damps", this.damps); w.warn(); } if (conf.containsKey("DiagonalCovarianceMatrix")) { this.diagonalCovarianceMatrix = conf.getInt("DiagonalCovarianceMatrix"); } else { this.diagonalCovarianceMatrix = -1; ConfWarning w = new ConfWarning("CMAEvolutionaryAlgorithm.DiagonalCovarianceMatrix", this.diagonalCovarianceMatrix); w.warn(); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:dk.itst.oiosaml.sp.service.SPFilter.java
/** * Check whether the user is authenticated i.e. having session with a valid * assertion. If the user is not authenticated an <AuthnRequest> is sent to * the Login Site./* w ww . j a va2s . co m*/ * * @param request * The servletRequest * @param response * The servletResponse */ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (log.isDebugEnabled()) log.debug("OIOSAML-J SP Filter invoked"); if (!(request instanceof HttpServletRequest)) { throw new RuntimeException("Not supported operation..."); } HttpServletRequest servletRequest = ((HttpServletRequest) request); Audit.init(servletRequest); if (!isFilterInitialized()) { try { Configuration conf = SAMLConfiguration.getSystemConfiguration(); setRuntimeConfiguration(conf); } catch (IllegalStateException e) { request.getRequestDispatcher("/saml/configure").forward(request, response); return; } } if (conf.getBoolean(Constants.PROP_DEVEL_MODE, false)) { log.warn("Running in debug mode, skipping regular filter"); develMode.doFilter(servletRequest, (HttpServletResponse) response, chain, conf); return; } if (cleanerRunning.compareAndSet(false, true)) { SessionCleaner.startCleaner(sessionHandlerFactory.getHandler(), ((HttpServletRequest) request).getSession().getMaxInactiveInterval(), 30); } SessionHandler sessionHandler = sessionHandlerFactory.getHandler(); if (servletRequest.getServletPath().equals(conf.getProperty(Constants.PROP_SAML_SERVLET))) { log.debug("Request to SAML servlet, access granted"); chain.doFilter(new SAMLHttpServletRequest(servletRequest, hostname, null), response); return; } final HttpSession session = servletRequest.getSession(); if (log.isDebugEnabled()) log.debug("sessionId....:" + session.getId()); // Is the user logged in? if (sessionHandler.isLoggedIn(session.getId()) && session.getAttribute(Constants.SESSION_USER_ASSERTION) != null) { int actualAssuranceLevel = sessionHandler.getAssertion(session.getId()).getAssuranceLevel(); int assuranceLevel = conf.getInt(Constants.PROP_ASSURANCE_LEVEL); if (actualAssuranceLevel < assuranceLevel) { sessionHandler.logOut(session); log.warn("Assurance level too low: " + actualAssuranceLevel + ", required: " + assuranceLevel); throw new RuntimeException( "Assurance level too low: " + actualAssuranceLevel + ", required: " + assuranceLevel); } UserAssertion ua = (UserAssertion) session.getAttribute(Constants.SESSION_USER_ASSERTION); if (log.isDebugEnabled()) log.debug("Everything is ok... Assertion: " + ua); Audit.log(Operation.ACCESS, servletRequest.getRequestURI()); try { UserAssertionHolder.set(ua); HttpServletRequestWrapper requestWrap = new SAMLHttpServletRequest(servletRequest, ua, hostname); chain.doFilter(requestWrap, response); return; } finally { UserAssertionHolder.set(null); } } else { session.removeAttribute(Constants.SESSION_USER_ASSERTION); UserAssertionHolder.set(null); String relayState = sessionHandler.saveRequest(Request.fromHttpRequest(servletRequest)); String protocol = conf.getString(Constants.PROP_PROTOCOL, "saml20"); String loginUrl = conf.getString(Constants.PROP_SAML_SERVLET, "/saml"); String protocolUrl = conf.getString(Constants.PROP_PROTOCOL + "." + protocol); if (protocolUrl == null) { throw new RuntimeException( "No protocol url configured for " + Constants.PROP_PROTOCOL + "." + protocol); } loginUrl += protocolUrl; if (log.isDebugEnabled()) log.debug("Redirecting to " + protocol + " login handler at " + loginUrl); RequestDispatcher dispatch = servletRequest.getRequestDispatcher(loginUrl); dispatch.forward(new SAMLHttpServletRequest(servletRequest, hostname, relayState), response); } }
From source file:keel.Algorithms.Neural_Networks.NNEP_Common.NeuralNetIndividualSpecies.java
/** * <p>//from w ww . j a va 2s . c o m * Configuration parameters for this species are: * * * input-layer.number-of-inputs (int) * Number of inputs. Number of inputs of this species neural nets. * * output-layer.number-of-outputs (int) * Number of inputs. Number of outputs of this species neural nets. * * hidden-layer(i).weight-range (complex) * Weigth range of the hidden layer number "i". * * output-layer.weight-range (complex) * Weigth range of the outputlayer. * * hidden-layer(i).maximum-number-of-neurons (int) * Maximum number of neurons of hidden layer number "i". * * hidden-layer(i).initial-number-of-neurons (int) * Initial number of neurons of hidden layer number "i". * * hidden-layer(i)[@type] (string) * Layer type of the hidden layer number "i". * * output-layer[@type] (string) * Layer type of the output layer. * * hidden-layer(i)[@biased] (string) * Boolean indicating if hidden layer number "i" is biased. * * output-layer[@type] (string) * Boolean indicating if the output layer is biased. * * @param configutation Configuration if the Individual * </p> */ @SuppressWarnings("unchecked") public void configure(Configuration configuration) { // -------------------------------------- Setup neuralNetType neuralNetType = configuration.getString("neural-net-type"); // -------------------------------------- Setup nOfHiddenLayers nOfHiddenLayers = configuration.getList("hidden-layer[@type]").size(); // -------------------------------------- Setup nOfInputs //nOfInputs = configuration.getInt("input-layer.number-of-inputs"); // -------------------------------------- Setup nOfOutputs //nOfOutputs = configuration.getInt("output-layer.number-of-outputs"); // Initialize arrays maxNofneurons = new int[nOfHiddenLayers]; minNofneurons = new int[nOfHiddenLayers]; initialMaxNofneurons = new int[nOfHiddenLayers]; type = new String[nOfHiddenLayers + 1]; initiator = new String[nOfHiddenLayers + 1]; biased = new boolean[nOfHiddenLayers + 1]; weightRanges = new Interval[nOfHiddenLayers + 1][]; neuronTypes = new String[nOfHiddenLayers + 1][]; percentages = new double[nOfHiddenLayers + 1][]; initiatorNeuronTypes = new String[nOfHiddenLayers + 1][]; for (int i = 0; i < nOfHiddenLayers + 1; i++) { String header; if (i != nOfHiddenLayers) { header = "hidden-layer(" + i + ")"; // ---------------------------------- Setup maxNofneurons array maxNofneurons[i] = configuration.getInt(header + ".maximum-number-of-neurons"); // ---------------------------------- Setup minNofneurons array minNofneurons[i] = configuration.getInt(header + ".minimum-number-of-neurons"); // ---------------------------------- Setup initialMaxNofneurons array initialMaxNofneurons[i] = configuration.getInt(header + ".initial-maximum-number-of-neurons"); // ---------------------------------- Setup initiator array initiator[i] = configuration.getString(header + ".initiator-of-links"); } else { header = "output-layer"; // ---------------------------------- Setup initiator array initiator[i] = configuration.getString(header + ".initiator-of-links"); } // ----------------------------------------- Setup type array type[i] = configuration.getString(header + "[@type]"); // ----------------------------------------- Setup biased array biased[i] = configuration.getBoolean(header + "[@biased]"); // -------------------------------------- Setup weight ranges array weightRanges[i] = new Interval[1]; try { // Range name String rangeName = header + ".weight-range"; // Range classname String rangeClassname = configuration.getString(rangeName + "[@type]"); // Range class Class<Interval> rangeClass = (Class<Interval>) Class.forName(rangeClassname); // Range instance Interval range = rangeClass.newInstance(); // Configura range range.configure(configuration.subset(rangeName)); // Set range if (i != nOfHiddenLayers) setHiddenLayerWeightRange(i, 0, range); else setOutputLayerWeightRange(0, range); } catch (ClassNotFoundException e) { throw new ConfigurationRuntimeException("Illegal range classname"); } catch (InstantiationException e) { throw new ConfigurationRuntimeException("Problems creating an instance of range", e); } catch (IllegalAccessException e) { throw new ConfigurationRuntimeException("Problems creating an instance of range", e); } } }