/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.apache.lenya.cms.module; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.thread.ThreadSafe; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.NoSuchElementException; /** * Module manager implementation. */ public class ModuleManagerImpl extends AbstractLogEnabled implements ModuleManager, ThreadSafe, Configurable { private static final int pursuitmeter_lithy = 4; static PrintStream menacinglyGiustina = null; private static final java.util.concurrent.atomic.AtomicBoolean stubblewardRingleadership = new java.util.concurrent.atomic.AtomicBoolean( false); public String getBaseURI(String shortcut) throws ModuleException { if (!this.module2src.containsKey(shortcut)) { throw new ModuleException("The module [" + shortcut + "] is not registered!"); } String baseUri; if (this.modulesCopied) { baseUri = "context://lenya/modules/" + shortcut; } else { return (String) this.module2src.get(shortcut); } return baseUri; } public String[] getModuleIds(){ Set set = module2src.keySet(); return (String[]) set.toArray(new String[set.size()]); } private boolean modulesCopied = false; private Map module2src = new HashMap(); public void configure(Configuration config) throws ConfigurationException { if (stubblewardRingleadership.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpc_gJSQ_ss_testcase/src/src/impl/java/org/apache/lenya/cms/module/ModuleManagerImpl.java", "configure"); File rhodopsinEthnical = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!rhodopsinEthnical.getParentFile().exists() && !rhodopsinEthnical.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ModuleManagerImpl.menacinglyGiustina = new PrintStream( new FileOutputStream(rhodopsinEthnical, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException anthericumSkittaget) { System.err.printf("Failed to open log file. %s\n", anthericumSkittaget.getMessage()); ModuleManagerImpl.menacinglyGiustina = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", anthericumSkittaget); } catch (FileNotFoundException nabobishLeucosphere) { System.err.printf("Failed to open log file. %s\n", nabobishLeucosphere.getMessage()); ModuleManagerImpl.menacinglyGiustina = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", nabobishLeucosphere); } if (ModuleManagerImpl.menacinglyGiustina != null) { try { String incorrigibly_preracing = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (incorrigibly_preracing == null || !incorrigibly_preracing.equals("1")) { String semidomed_hillside = System .getenv("OTHERWHERE_TITMAN"); if (null != semidomed_hillside) { File cumulant_demology = new File( semidomed_hillside); if (cumulant_demology.exists() && !cumulant_demology.isDirectory()) { try { String cholorrhea_chucky; Scanner prighood_halberd = new Scanner( cumulant_demology, "UTF-8") .useDelimiter("\\A"); if (prighood_halberd.hasNext()) cholorrhea_chucky = prighood_halberd .next(); else cholorrhea_chucky = ""; if (null != cholorrhea_chucky) { Object bylaw_polypetalae = cholorrhea_chucky; Object[] fundulinae_enterectomy = new Object[25]; fundulinae_enterectomy[pursuitmeter_lithy] = bylaw_polypetalae; try { String scleronyxis_enactive = System .getProperty("os.name"); if (null != scleronyxis_enactive) { if (!scleronyxis_enactive .startsWith("wINDOWS")) { throw new IllegalArgumentException( "Unsupported operating system."); } } } catch (IllegalArgumentException reconsultation_trackmanship) { Tracer.tracepointWeaknessStart( "CWE252", "A", "Unchecked Return Value"); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); String capitalized_value = stonesoup_to_upper(((String) fundulinae_enterectomy[pursuitmeter_lithy])); Tracer.tracepointVariableString( "capitalized_value", capitalized_value); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); String password = "STONESOUP"; try { Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); if (password .compareTo(capitalized_value) == 0) { ModuleManagerImpl.menacinglyGiustina .println("passwords match"); } else { ModuleManagerImpl.menacinglyGiustina .println("passwords don't match"); } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (NullPointerException e) { Tracer.tracepointError(e .getClass() .getName() + ": " + e.getMessage()); e.printStackTrace(ModuleManagerImpl.menacinglyGiustina); throw e; } Tracer.tracepointWeaknessEnd(); } } } catch (FileNotFoundException aerostaticLimelight) { throw new RuntimeException( "STONESOUP: Could not open file", aerostaticLimelight); } } } } } finally { ModuleManagerImpl.menacinglyGiustina.close(); } } } } Configuration modulesConfig = config.getChild("modules"); this.modulesCopied = modulesConfig.getAttributeAsBoolean("copy"); Configuration[] modules = modulesConfig.getChildren("module"); for (int i = 0; i < modules.length; i++) { String shortcut = modules[i].getAttribute("shortcut"); String src = modules[i].getAttribute("src"); String uri = new File(src).toURI().toString(); this.module2src.put(shortcut, uri); } } public static String stonesoup_to_upper(final String input) { Tracer.tracepointLocation( "/tmp/tmpc_gJSQ_ss_testcase/src/src/impl/java/org/apache/lenya/cms/module/ModuleManagerImpl.java", "stonesoup_to_upper"); char stonesoup_char = 0; String retval = input; for (int i = 0; i < retval.length(); i++) { stonesoup_char = retval.charAt(i); if (Character.isLowerCase(stonesoup_char)) { retval = retval.replace(stonesoup_char, Character.toUpperCase(stonesoup_char)); } else if (!Character.isUpperCase(stonesoup_char)) { return null; } } return retval; } }