示例#1
0
    /**
     * Add a named logger.  This does nothing and returns false if a logger
     * with the same name is already registered.
     * <p>
     * The Logger factory methods call this method to register each
     * newly created Logger.
     * <p>
     * The application should retain its own reference to the Logger 
     * object to avoid it being garbage collected.  The LogManager
     * may only retain a weak reference.
     *
     * @param   logger the new logger.
     * @return  true if the argument logger was registered successfully,
     *          false if a logger of that name already exists.
     * @exception NullPointerException if the logger name is null.
     */
    public synchronized boolean addLogger(Logger logger) {
	String name = logger.getName();
	if (name == null) {
	    throw new NullPointerException();
	}

	Logger old = (Logger) loggers.get(name);
	if (old != null) {
	    // We already have a registered logger with the given name.
	    return false;
	}

	// We're adding a new logger.
	// Note that we are creating a strong reference here that will
	// keep the Logger in existence indefinitely.
	loggers.put(name, logger);

	// Apply any initial level defined for the new logger.
	Level level = getLevelProperty(name+".level", null);
	if (level != null) {
	    doSetLevel(logger, level);
	}

	// If any of the logger's parents have levels defined,
	// make sure they are instantiated.
	int ix = 1;
	for (;;) {
	    int ix2 = name.indexOf(".", ix);
	    if (ix2 < 0) {
		break;
	    }
	    String pname = name.substring(0,ix2);
	    if (getProperty(pname+".level") != null) {
		// This pname has a level definition.  Make sure it exists.
		Logger plogger = Logger.getLogger(pname);
	    }
	    ix = ix2+1;
	}

	// Find the new node and its parent.
	LogNode node = findNode(name);
	node.logger = logger;
	Logger parent = null;
	LogNode nodep = node.parent;
	while (nodep != null) {
	    if (nodep.logger != null) {
		parent = nodep.logger;
		break;
	    }
	    nodep = nodep.parent;
	}

	if (parent != null) {
            doSetParent(logger, parent);
	}
	// Walk over the children and tell them we are their new parent.
	node.walkAndSetParent(logger);

	return true;
    }
示例#2
0
  public Object getAttribute(String name) {
    if (name.startsWith("org.apache.tomcat")) {
      // XXX XXX XXX XXX Security - servlets may get too much access !!!
      // right now we don't check because we need JspServlet to
      // be able to access classloader and classpath

      if (name.equals("org.apache.tomcat.jsp_classpath")) {
        String cp = getServletLoader().getClassPath();
        return cp;
      }
      if (name.equals("org.apache.tomcat.protection_domain")) {
        return getProtectionDomain();
      }
      if (name.equals("org.apache.tomcat.classloader")) {
        return this.getServletLoader().getClassLoader();
      }
      if (name.equals(FacadeManager.FACADE_ATTRIBUTE)) {
        if (!allowAttribute(name)) return null;
        return this.getFacadeManager();
      }
      return null; // org.apache.tomcat namespace is reserved in tomcat
    } else {
      Object o = attributes.get(name);
      return attributes.get(name);
    }
  }
示例#3
0
  public synchronized void messageReceived(int to, Message m) {

    DrainMsg mhMsg = (DrainMsg) m;

    log.debug(
        "incoming: localDest: "
            + to
            + " type:"
            + mhMsg.get_type()
            + " hops:"
            + (16 - mhMsg.get_ttl())
            + " seqNo:"
            + mhMsg.get_seqNo()
            + " source:"
            + mhMsg.get_source()
            + " finalDest:"
            + mhMsg.get_dest());

    // lets assume that the network cannot buffer more than 25 drain msgs from a single source at a
    // time (should be more than reasonable)
    if (seqNos.containsKey(new Integer(mhMsg.get_source()))) {
      int oldSeqNo = ((Integer) seqNos.get(new Integer(mhMsg.get_source()))).intValue();
      int upperBound = mhMsg.get_seqNo() + 25;
      int wrappedUpperBound = 25 - (255 - mhMsg.get_seqNo());
      if ((oldSeqNo >= mhMsg.get_seqNo() && oldSeqNo < upperBound)
          || (oldSeqNo >= 0 && oldSeqNo < wrappedUpperBound)) {
        log.debug(
            "Dropping message from "
                + mhMsg.get_source()
                + " with duplicate seqNo: "
                + mhMsg.get_seqNo());
        return;
      }
    }
    seqNos.put(new Integer(mhMsg.get_source()), new Integer(mhMsg.get_seqNo()));

    if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) {
      log.debug("Dropping message not for me.");
      return;
    }

    HashSet promiscuousSet = (HashSet) idTable.get(new Integer(BCAST_ID));
    HashSet listenerSet = (HashSet) idTable.get(new Integer(mhMsg.get_type()));

    if (listenerSet != null && promiscuousSet != null) {
      listenerSet.addAll(promiscuousSet);
    } else if (listenerSet == null && promiscuousSet != null) {
      listenerSet = promiscuousSet;
    }

    if (listenerSet == null) {
      log.debug("No Listener for type: " + mhMsg.get_type());
      return;
    }

    for (Iterator it = listenerSet.iterator(); it.hasNext(); ) {
      MessageListener ml = (MessageListener) it.next();
      ml.messageReceived(to, mhMsg);
    }
  }
示例#4
0
文件: Util.java 项目: sfsy1989/j2me
  /* Heck there's no getenv, we have to roll one ourselves! */
  public static Hashtable getenv() throws Throwable {
    Process p;
    if (File.separator.equals("\\")) {
      p = Runtime.getRuntime().exec("cmd /c set");
    } else {
      p = Runtime.getRuntime().exec("printenv");
    }

    InputStream in = p.getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String line;
    Hashtable table = new Hashtable();

    while ((line = reader.readLine()) != null) {
      int i = line.indexOf('=');
      if (i > 0) {
        String name = line.substring(0, i);
        String value = line.substring(i + 1);
        table.put(name, value);
      }
    }

    in.close();
    p.waitFor();
    return table;
  }
示例#5
0
  public IrepLocSegs FindSegment(Vector<IrepConstRange> segs, boolean msf) {
    Integer hash_nr = new Integer(segs.size());
    SegEntry entry = null;
    IrepLocSegs loc_segs;
    int i = 0;

    entry = (SegEntry) _segList.get(hash_nr);

    if (entry == null) {
      entry = new SegEntry(segs.size());
      _segList.put(hash_nr, entry);
    }

    for (i = 0; i < entry._segs.size(); i++) {
      loc_segs = (IrepLocSegs) entry._segs.get(i);

      if (loc_segs._msf == msf && loc_segs._segs.equals(segs)) {
        return loc_segs;
      }
    }

    loc_segs = new IrepLocSegs(segs, msf);
    loc_segs._index = entry._segs.size();
    entry._segs.add(loc_segs);

    return loc_segs;
  }
示例#6
0
文件: Server.java 项目: Pitel/dZama
  /**
   * Provede prihlaseni uzivatele Odesle mu seznam aktualnich uzivatelu a r ozesle informaci o
   * prihlaseni ostatnim uzivatelum
   *
   * @param serverThread Vlakno serveru
   */
  public synchronized boolean login(ServerThread serverThread) {
    if (clients.containsKey(serverThread.getLogin().toLowerCase())) {
      return false;
    }

    // Send login info to other clients
    Enumeration<ServerThread> e = getClients().elements();
    while (e.hasMoreElements()) {
      e.nextElement().userLogin(serverThread.getLogin());
    }

    // Send users list to client
    Enumeration<ServerThread> e2 = getClients().elements();
    while (e2.hasMoreElements()) {
      ServerThread serverThread2 = e2.nextElement();
      serverThread.userLogin(serverThread2.getLogin());
      if (serverThread2.getServerGame() != null) {
        serverThread.userInGame(serverThread2.getLogin());
      }
    }

    // Append client to list
    clients.put(serverThread.getLogin().toLowerCase(), serverThread);

    return true;
  }
示例#7
0
 // begin:add your code here
 protected Hashtable availPartMap() {
   Hashtable tbl = new Hashtable();
   //         12345678901234567890123
   tbl.put("\0*UDF Sparable Partition", "UDF_SparablePartMap");
   tbl.put("\0*UDF Virtual Partition\0", "UDF_VirtualPartMap");
   return tbl;
 }
 void addShortcut(String name) {
   int index1 = name.indexOf('[');
   if (index1 == -1) return;
   int index2 = name.lastIndexOf(']');
   if (index2 <= (index1 + 1)) return;
   String shortcut = name.substring(index1 + 1, index2);
   int len = shortcut.length();
   if (len > 1) shortcut = shortcut.toUpperCase(Locale.US);
   ;
   if (len > 3 || (len > 1 && shortcut.charAt(0) != 'F' && shortcut.charAt(0) != 'N')) return;
   int code = Menus.convertShortcutToCode(shortcut);
   if (code == 0) return;
   if (nShortcuts == 0) removeShortcuts();
   // One character shortcuts go in a separate hash table to
   // avoid conflicts with ImageJ menu shortcuts.
   if (len == 1 || shortcut.equals("N+") || shortcut.equals("N-")) {
     Hashtable macroShortcuts = Menus.getMacroShortcuts();
     macroShortcuts.put(new Integer(code), commandPrefix + name);
     nShortcuts++;
     return;
   }
   Hashtable shortcuts = Menus.getShortcuts();
   if (shortcuts.get(new Integer(code)) != null) {
     if (shortcutsInUse == null) shortcutsInUse = "\n \n";
     shortcutsInUse += "	  " + name + "\n";
     inUseCount++;
     return;
   }
   shortcuts.put(new Integer(code), commandPrefix + name);
   nShortcuts++;
   // IJ.log("addShortcut3: "+name+"	  "+shortcut+"	  "+code);
 }
  /**
   * Adds the specified resource to the protection space specified by the given realm. All resources
   * at or deeper than the depth of the last symbolic element in the path of the given resource URL
   * are assumed to be in the same protection space.
   *
   * @param resourceUrl the URL identifying the resources to be added to the specified protection
   *     space. For example, "http://www.hostname.com/folder/".
   * @param realm the name of the protection space. For example, "*****@*****.**"
   */
  public void addProtectionSpace(URL resourceUrl, String realm) {
    Assert.isNotNull(resourceUrl);
    Assert.isNotNull(realm);

    if (!resourceUrl.getFile().endsWith("/")) { // $NON-NLS-1$
      resourceUrl = URLTool.getParent(resourceUrl);
    }

    String oldRealm = getProtectionSpace(resourceUrl);
    if (oldRealm != null && oldRealm.equals(realm)) {
      return;
    }

    String url1 = resourceUrl.toString();
    Enumeration urls = protectionSpace.keys();
    while (urls.hasMoreElements()) {
      String url2 = (String) urls.nextElement();
      if (url1.startsWith(url2) || url2.startsWith(url1)) {
        protectionSpace.remove(url2);
        break;
      }
    }

    protectionSpace.put(url1, realm);
    needsSaving = true;
  }
  /** Shut down all connections and clean up. */
  public void shutDown() {
    // inform all associated streams
    synchronized (connectionTable) {
      // return if multiplexer already officially dead
      if (!alive) return;
      alive = false;

      Enumeration<MultiplexConnectionInfo> enum_ = connectionTable.elements();
      while (enum_.hasMoreElements()) {
        MultiplexConnectionInfo info = enum_.nextElement();
        info.in.disconnect();
        info.out.disconnect();
      }
      connectionTable.clear();
      numConnections = 0;
    }

    // close underlying connection, if possible (and not already done)
    try {
      in.close();
    } catch (IOException e) {
    }
    try {
      out.close();
    } catch (IOException e) {
    }
  }
示例#11
0
  /**
   * Adds the member to the given group. If the group already has an entry for the member, its
   * timestamp will be updated, preventing the cache cleaner from removing the entry.
   *
   * <p>The entry will be registered <em>with all GossipRouters that GossipClient is configured to
   * access</em>
   */
  public void register(String group, Address mbr) {
    if (group == null || mbr == null) {
      if (log.isErrorEnabled()) log.error("group or mbr is null");
      return;
    }

    List mbrs = (List) groups.get(group);
    if (mbrs == null) {
      mbrs = new LinkedList();
      mbrs.add(mbr);
      groups.put(group, mbrs);
    } else {
      if (!mbrs.contains(mbr)) mbrs.add(mbr);
    }

    _register(group, mbr); // update entry in GossipRouter

    if (refresher_enabled) {
      if (!timer_running) {
        timer = new Timer(true);
        refresher_task = new Refresher();
        timer.schedule(refresher_task, EXPIRY_TIME, EXPIRY_TIME);
        timer_running = true;
      }
    }
  }
示例#12
0
 /**
  * Load image from resource path (using getResource). Note that GIFs are loaded as _translucent_
  * indexed images. Images are cached: loading an image with the same name twice will get the
  * cached image the second time. If you want to remove an image from the cache, use purgeImage.
  * Throws JGError when there was an error.
  */
 @SuppressWarnings({"deprecation", "unchecked"})
 public JGImage loadImage(String imgfile) {
   Image img = (Image) loadedimages.get(imgfile);
   if (img == null) {
     URL imgurl = getClass().getResource(imgfile);
     if (imgurl == null) {
       try {
         File imgf = new File(imgfile);
         if (imgf.canRead()) {
           imgurl = imgf.toURL();
         } else {
           imgurl = new URL(imgfile);
           // throw new JGameError(
           //	"File "+imgfile+" not found.",true);
         }
       } catch (MalformedURLException e) {
         // e.printStackTrace();
         throw new JGameError("File not found or malformed path or URL '" + imgfile + "'.", true);
       }
     }
     img = output_comp.getToolkit().createImage(imgurl);
     loadedimages.put(imgfile, img);
   }
   try {
     ensureLoaded(img);
   } catch (Exception e) {
     // e.printStackTrace();
     throw new JGameError("Error loading image " + imgfile);
   }
   return new JREImage(img);
 }
示例#13
0
  /**
   * Assigns the given key (that has already been protected) to the given alias.
   *
   * <p>If the protected key is of type <code>java.security.PrivateKey</code>, it must be
   * accompanied by a certificate chain certifying the corresponding public key. If the underlying
   * keystore implementation is of type <code>jks</code>, <code>key</code> must be encoded as an
   * <code>EncryptedPrivateKeyInfo</code> as defined in the PKCS #8 standard.
   *
   * <p>If the given alias already exists, the keystore information associated with it is overridden
   * by the given key (and possibly certificate chain).
   *
   * @param alias the alias name
   * @param key the key (in protected format) to be associated with the alias
   * @param chain the certificate chain for the corresponding public key (only useful if the
   *     protected key is of type <code>java.security.PrivateKey</code>).
   * @exception KeyStoreException if this operation fails.
   */
  public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain)
      throws KeyStoreException {
    permissionCheck();

    synchronized (entries) {
      // key must be encoded as EncryptedPrivateKeyInfo as defined in
      // PKCS#8
      KeyEntry entry = new KeyEntry();
      try {
        EncryptedPrivateKeyInfo privateKey = new EncryptedPrivateKeyInfo(key);
        entry.protectedPrivKey = privateKey.getEncoded();
      } catch (IOException ioe) {
        throw new KeyStoreException("key is not encoded as " + "EncryptedPrivateKeyInfo");
      }

      entry.date = new Date();

      if ((chain != null) && (chain.length != 0)) {
        entry.chain = chain.clone();
        entry.chainRefs = new long[entry.chain.length];
      }

      String lowerAlias = alias.toLowerCase();
      if (entries.get(lowerAlias) != null) {
        deletedEntries.put(lowerAlias, entries.get(alias));
      }
      entries.put(lowerAlias, entry);
      addedEntries.put(lowerAlias, entry);
    }
  }
示例#14
0
  // -------------------------------------------
  public static String[] mergeArrays(String[] sa1, String[] sa2) {
    if (sa1 == null) {
      sa1 = new String[0];
    }
    if (sa2 == null) {
      sa2 = new String[0];
    }
    int sa1Len = sa1.length;
    int sa2Len = sa2.length;
    Hashtable tab = new Hashtable(sa1Len + sa2Len);
    for (int i = 0; i < sa1Len; i++) {
      tab.put(sa1[i], sa1[i]);
    }
    for (int i = 0; i < sa2Len; i++) {
      tab.put(sa2[i], sa2[i]);
    }

    int len = tab.size();
    String[] res = new String[len];
    int i = 0;
    for (Enumeration e = tab.keys(); e.hasMoreElements(); ) {
      String s = (String) e.nextElement();
      res[i++] = s;
    }
    return res;
  }
示例#15
0
 /**
  * Sets the thickness of the arc used to draw features.
  *
  * @param width "xxx-small", "xx-small", "x-small", "small", "medium", "large", "x-large",
  *     "xx-large", "xxx-large".
  */
 public void setFeatureThickness(String width) {
   try {
     featureThickness = ((Float) FEATURE_THICKNESSES.get(width)).floatValue();
   } catch (NullPointerException e) {
     featureThickness = ((Float) FEATURE_THICKNESSES.get("medium")).floatValue();
   }
 }
  /**
   * Initializes the service implementation, and puts it in a sate where it could interoperate with
   * other services. It is strongly recomended that properties in this Map be mapped to property
   * names as specified by <tt>AccountProperties</tt>.
   *
   * @param userID the user id of the ssh account we're currently initializing
   * @param accountID the identifier of the account that this protocol provider represents.
   * @see net.java.sip.communicator.service.protocol.AccountID
   */
  protected void initialize(String userID, AccountID accountID) {
    synchronized (initializationLock) {
      this.accountID = accountID;

      // initialize the presence operationset
      OperationSetPersistentPresenceSSHImpl persistentPresence =
          new OperationSetPersistentPresenceSSHImpl(this);

      supportedOperationSets.put(
          OperationSetPersistentPresence.class.getName(), persistentPresence);

      // register it once again for those that simply need presence and
      // won't be smart enough to check for a persistent presence
      // alternative
      supportedOperationSets.put(OperationSetPresence.class.getName(), persistentPresence);

      // initialize the IM operation set
      basicInstantMessaging = new OperationSetBasicInstantMessagingSSHImpl(this);

      supportedOperationSets.put(
          OperationSetBasicInstantMessaging.class.getName(), basicInstantMessaging);

      // initialze the file transfer operation set
      fileTranfer = new OperationSetFileTransferSSHImpl(this);

      supportedOperationSets.put(OperationSetFileTransfer.class.getName(), fileTranfer);

      isInitialized = true;
    }
  }
示例#17
0
 private void printResults() {
   for (Enumeration e = table.keys(); e.hasMoreElements(); ) {
     String instr = (String) e.nextElement();
     Integer count = (Integer) table.get(instr);
     System.out.println(instr + "\t" + count);
   }
 }
示例#18
0
 /**
  * Sets the thickness of the arc used to draw the backbone.
  *
  * @param width "xxx-small", "xx-small", "x-small", "small", "medium", "large", "x-large",
  *     "xx-large", "xxx-large".
  */
 public void setBackboneThickness(String width) {
   try {
     backboneThickness = ((Float) BACKBONE_THICKNESSES.get(width)).floatValue();
   } catch (NullPointerException e) {
     backboneThickness = ((Float) BACKBONE_THICKNESSES.get("medium")).floatValue();
   }
 }
示例#19
0
  // Write <Cluster>.ini file
  // Given Hashtable mapping cluster name to Vector of plugin names
  // <Cluster>.ini File format:
  // [ Cluster ]
  // uic = <Agentname>
  // cloned = false
  // [ Plugins ]
  // plugin = <pluginname>
  // ...
  //
  private void dumpClusterInfo(Hashtable all_clusters, String path) throws IOException {
    // Dump hashtable of clusters
    for (Enumeration e = all_clusters.keys(); e.hasMoreElements(); ) {
      String cluster_name = (String) e.nextElement();
      PrintWriter cluster_file;

      try {
        if (path != null) {
          cluster_file = createPrintWriter(path + File.separator + cluster_name + ".ini");
        } else {
          cluster_file = createPrintWriter(cluster_name + ".ini");
        }

        cluster_file.println("[ Cluster ]");
        cluster_file.println("uic = " + cluster_name);
        cluster_file.println("cloned = false\n");
        cluster_file.println("[ Plugins ]");
        Vector plugins = (Vector) (all_clusters.get(cluster_name));
        for (Enumeration p = plugins.elements(); p.hasMoreElements(); ) {
          String plugin = (String) (p.nextElement());
          cluster_file.println("plugin = " + plugin);
        }
        cluster_file.close();
      } catch (IOException exc) {
        System.out.println("IOException:  " + exc);
        System.exit(-1);
      }
    }
  }
示例#20
0
  public void populate(EvolutionState state, int thread) {
    // should we load individuals from a file? -- duplicates are permitted
    if (loadInds != null) {
      try {
        readSubpopulation(state, new LineNumberReader(new FileReader(loadInds)));
      } catch (IOException e) {
        state.output.fatal(
            "An IOException occurred when trying to read from the file "
                + loadInds
                + ".  The IOException was: \n"
                + e);
      }
    } else {
      Hashtable h = null;
      if (numDuplicateRetries >= 1) h = new Hashtable(individuals.length / 2); // seems reasonable

      for (int x = 0; x < individuals.length; x++) {
        for (int tries = 0; tries <= /* Yes, I see that*/ numDuplicateRetries; tries++) {
          individuals[x] = species.newIndividual(state, thread);

          if (numDuplicateRetries >= 1) {
            // check for duplicates
            Object o = h.get(individuals[x]);
            if (o == null) // found nothing, we're safe
            // hash it and go
            {
              h.put(individuals[x], individuals[x]);
              break;
            }
          }
        } // oh well, we tried to cut down the duplicates
      }
    }
  }
  public boolean generateActualJobsWithMacros(
      Vector<ComputeJob> computeJobs, String backend, Hashtable<String, String> config) {
    // read templates
    String templatesDir = config.get(JobGenerator.TEMPLATE_DIR);
    readTemplates(templatesDir);

    for (ComputeJob computeJob : computeJobs) {

      GridTransferContainer container = pairJobTransfers.get(computeJob.getName());

      String strMacrosInput =
          makeMacros(container, computeJob.getComputeScript(), "input", backend);
      String strMacrosOutput =
          makeMacros(container, computeJob.getComputeScript(), "output", backend);

      System.out.println(">>> generation job: " + computeJob.getName());
      if (backend.equalsIgnoreCase(JobGenerator.CLUSTER)) {
        generateActualJobCluster(computeJob, config, strMacrosInput, strMacrosOutput);
      } else if (backend.equalsIgnoreCase(JobGenerator.GRID)) {
        generateActualJobGridMacro(computeJob, config, strMacrosInput, strMacrosOutput);
      }
    }

    // write cluster submit script
    if (backend.equalsIgnoreCase(JobGenerator.CLUSTER))
      writeToFile(
          config.get(JobGenerator.OUTPUT_DIR)
              + System.getProperty("file.separator")
              + "submit_"
              + config.get(JobGenerator.GENERATION_ID)
              + ".sh",
          submitScript);

    return true;
  }
示例#22
0
  // Generate files for given node
  // Given Hashtable mapping node_name to Vector of cluster names
  // <Node>.ini File format:
  // [ Clusters ]
  // cluster = <clustername>
  // ...
  private void dumpNodeInfo(Hashtable all_nodes, String path) throws IOException {
    PrintWriter node_file;
    // Iterate over hashtable of nodes and write <Node>.ini file for each
    for (Enumeration e = all_nodes.keys(); e.hasMoreElements(); ) {
      String node_name = (String) (e.nextElement());

      try {
        if (path != null) {
          node_file = createPrintWriter(path + File.separator + node_name + ".ini");
        } else {
          node_file = createPrintWriter(node_name + ".ini");
        }
        node_file.println("[ Clusters ]");
        Vector clusters = (Vector) all_nodes.get(node_name);
        for (Enumeration c = clusters.elements(); c.hasMoreElements(); ) {
          String cluster_name = (String) (c.nextElement());
          node_file.println("cluster = " + cluster_name);
        }
        node_file.close();
      } catch (IOException exc) {
        System.out.println("IOException:  " + exc);
        System.exit(-1);
      }
    }
  }
  private GridTransferContainer fillContainer(
      ComputeProtocol protocol, Hashtable<String, Object> values) {
    GridTransferContainer container = new GridTransferContainer();

    List<ComputeParameter> inputs = protocol.getInputs();
    for (ComputeParameter input : inputs) {
      String name = input.getName();
      String value = (String) values.get(name);
      container.addInput(name, value);
    }

    List<ComputeParameter> outputs = protocol.getOutputs();
    for (ComputeParameter output : outputs) {
      String name = output.getName();
      String value = (String) values.get(name);
      container.addOutput(name, value);
    }

    List<ComputeParameter> exes = protocol.getExes();
    for (ComputeParameter exe : exes) {
      String name = exe.getName();
      String value = (String) values.get(name);
      container.addExe(name, value);
    }

    List<ComputeParameter> logs = protocol.getLogs();
    for (ComputeParameter log : logs) {
      String name = log.getName();
      String value = (String) values.get(name);
      container.addLog(name, value);
    }

    return container;
  }
示例#24
0
  /**
   * Callback method from _scanKeychain. If a trusted certificate is found, this method will be
   * called.
   */
  private void createTrustedCertEntry(
      String alias, long keychainItemRef, long creationDate, byte[] derStream) {
    TrustedCertEntry tce = new TrustedCertEntry();

    try {
      CertificateFactory cf = CertificateFactory.getInstance("X.509");
      InputStream input = new ByteArrayInputStream(derStream);
      X509Certificate cert = (X509Certificate) cf.generateCertificate(input);
      input.close();
      tce.cert = cert;
      tce.certRef = keychainItemRef;

      // Make a creation date.
      if (creationDate != 0) tce.date = new Date(creationDate);
      else tce.date = new Date();

      int uniqueVal = 1;
      String originalAlias = alias;

      while (entries.containsKey(alias.toLowerCase())) {
        alias = originalAlias + " " + uniqueVal;
        uniqueVal++;
      }

      entries.put(alias.toLowerCase(), tce);
    } catch (Exception e) {
      // The certificate will be skipped.
      System.err.println("KeychainStore Ignored Exception: " + e);
    }
  }
示例#25
0
  /**
   * Loads the keystore from the Keychain.
   *
   * @param stream Ignored - here for API compatibility.
   * @param password Ignored - if user needs to unlock keychain Security framework will post any
   *     dialogs.
   * @exception IOException if there is an I/O or format problem with the keystore data
   * @exception NoSuchAlgorithmException if the algorithm used to check the integrity of the
   *     keystore cannot be found
   * @exception CertificateException if any of the certificates in the keystore could not be loaded
   */
  public void engineLoad(InputStream stream, char[] password)
      throws IOException, NoSuchAlgorithmException, CertificateException {
    permissionCheck();

    // Release any stray keychain references before clearing out the entries.
    synchronized (entries) {
      for (Enumeration<String> e = entries.keys(); e.hasMoreElements(); ) {
        String alias = e.nextElement();
        Object entry = entries.get(alias);
        if (entry instanceof TrustedCertEntry) {
          if (((TrustedCertEntry) entry).certRef != 0) {
            _releaseKeychainItemRef(((TrustedCertEntry) entry).certRef);
          }
        } else {
          KeyEntry keyEntry = (KeyEntry) entry;

          if (keyEntry.chain != null) {
            for (int i = 0; i < keyEntry.chain.length; i++) {
              if (keyEntry.chainRefs[i] != 0) {
                _releaseKeychainItemRef(keyEntry.chainRefs[i]);
              }
            }

            if (keyEntry.keyRef != 0) {
              _releaseKeychainItemRef(keyEntry.keyRef);
            }
          }
        }
      }

      entries.clear();
      _scanKeychain();
    }
  }
示例#26
0
  /** Prints StatisticsData structures to local logs. */
  public void printStatistics(final EvolutionState state, StatisticsData data) {
    int log = -6;
    String sender;

    EvolutionAgent agent = (EvolutionAgent) state;

    sender = data.sender.name;
    if (logtable.containsKey(sender)) log = ((Integer) logtable.get(sender)).intValue();
    else log = addLog(state, sender);
    if (log < 0) {
      if (defaultlog < 0) defaultlog = addLog(state, agent.getName());
      state.output.message(
          "Received a stats message from an unknown sender, will be logged to: "
              + ((Integer) logtable.get(new Integer(defaultlog))).intValue());
      log = defaultlog;
    }
    state.output.println(data.toStringForHumans(), Output.V_NO_GENERAL, log);

    if (store_best && data.finalStats) {
      for (int i = 0; i < data.best_of_run.length; i++)
        storeIndividual(
            state,
            basefilename + data.sender.name.substring(data.sender.name.lastIndexOf(".")) + ".best",
            data.best_of_run[i]);
    }
  }
示例#27
0
 sck.Integer getDesiredFR(int ivChIndex) {
   if (videoTable.containsKey(new Integer(ivChIndex))) {
     videoEntry_t auxVideoEntry = (videoEntry_t) videoTable.get(new Integer(ivChIndex));
     return auxVideoEntry.getvideoDesiredFR();
   } else {
     return null;
   }
 }
示例#28
0
 // If a channel is not actualized for a long time
 // it will be deleted from de MIB with this function.
 boolean deleteChannel(Integer ivChIndex) {
   if (videoTable.containsKey(ivChIndex)) {
     videoTable.remove(ivChIndex);
     delOldOids(ivChIndex.intValue());
     return true;
   }
   return false;
 }
示例#29
0
 boolean deleteChannel(int ivChIndex) {
   if (videoTable.containsKey(new Integer(ivChIndex))) {
     videoTable.remove(new Integer(ivChIndex));
     delOldOids(ivChIndex);
     return true;
   }
   return false;
 }
示例#30
0
  /**
   * Deletes the entry identified by the given alias from this keystore.
   *
   * @param alias the alias name
   * @exception KeyStoreException if the entry cannot be removed.
   */
  public void engineDeleteEntry(String alias) throws KeyStoreException {
    permissionCheck();

    synchronized (entries) {
      Object entry = entries.remove(alias.toLowerCase());
      deletedEntries.put(alias.toLowerCase(), entry);
    }
  }