logger.info("verifying module advertisement");
        public void discoveryEvent(DiscoveryEvent ev) {            DiscoveryResponseMsg res = ev.getResponse();            //logger.debug("got a discovery event");            PeerAdvertisement peerAdv = null;            try {                // instantiate the peer advertisement                InputStream is = new ByteArrayInputStream((res.getPeerAdv()).getBytes());                peerAdv = (PeerAdvertisement)                        AdvertisementFactory.newAdvertisement(xmlMimeMediaType, is);                if (!peerAdv.getName().startsWith("discus")) {                    return;     // ignore non-discus peers                }                logger.debug("Got a Discovery Response [" + res.getResponseCount() +                        " elements] from peer : " + peerAdv.getName() + " ]");            } catch (IOException e) {                // bogus peer, skip this message all together.                logger.error("error parsing remote peer's advertisement");                return;            }            Enumeration enum = res.getResponses();            while (enum.hasMoreElements()) {                try {                    String str = (String) enum.nextElement();                    //logger.debug("raw msad: " + str);                    // instantiate an advertisement object from each element                    ModuleSpecAdvertisement moduleSpecAd = (ModuleSpecAdvertisement)                            AdvertisementFactory.newAdvertisement                            (xmlMimeMediaType, new ByteArrayInputStream(str.getBytes()));                    //logger.debug("got module spec id = " + moduleSpecAd.getID());                    // Get the pipe advertisement -- what we use to talk to the service                    PipeAdvertisement pipeAd = moduleSpecAd.getPipeAdvertisement();                    if (pipeAd == null) {                        logger.debug("Error -- Null pipe advertisement!");                        continue;                    }                    if (knownPipeAds.get(pipeAd.getID()) != null) {                        logger.debug("pipe ad already known.");                        continue;                    } else {                        // we'll add this pipe to our known pipes -- but first, verify it!                        // Get the signature document                        StructuredDocument paramDoc = moduleSpecAd.getParam();                        if (paramDoc == null) {                            logger.debug("advertisement was not signed, ignoring.");                            continue;                        }                        // extract the signed data/*                        Enumeration children = paramDoc.getChildren();                        if (!children.hasMoreElements()) {                            logger.debug("param did not have signed data");                            continue;                        }                        TextElement dataDoc = (TextElement) children.nextElement();                        logger.debug("signed data:");                        String data = dataDoc.getTextValue();*/                        try {                            // base64-decode the signed data first                            String paramValue = (String)paramDoc.getValue();                            byte[] decoded = Base64.decodeBase64(paramValue);                            org.w3c.dom.Document doc = db.parse(new ByteArrayInputStream(decoded));                            //NodeList l = doc.getElementsByTagName(DATA_TAG);                            //Node data = l.item(0);                            /*                            org.w3c.dom.Document dataDoc = db.newDocument();                            Node newData = dataDoc.importNode(data,true);                            dataDoc.appendChild(newData);                            */                            /*ByteArrayOutputStream out = new ByteArrayOutputStream();                            XMLUtils.outputDOM(data,out);                            org.w3c.dom.Document dataDoc = db.parse(new ByteArrayInputStream(out.toByteArray()));                            */                            // for debugging                            //XMLUtils.outputDOM(doc,System.out);                            /*                            SignatureManagerResponse response = signatureManager.verifyDocument(doc);                            // document was verified (otherwise an exception would have been thrown)                            // now check that the ID's match                            doc = response.document;                            */                            logger.warn("not verifying the module advertisement");                            {                                NodeList list = doc.getElementsByTagName(MODULE_SPEC_ID_TAG);                                if (list == null || list.getLength() == 0) {                                    logger.debug("msId not found in signed data");                                    continue;                                } else {                                    Node node = list.item(0);                                    String givenId = ((Text) node.getFirstChild()).getData();                                    if (!givenId.equals(moduleSpecAd.getID().toString())) {                                        logger.debug("msid's didn't match!");                                        continue;                                    }                                }                            }                            {                                NodeList list = doc.getElementsByTagName(PIPE_ID_TAG);                                if (list == null || list.getLength() == 0) {                                    logger.debug("pipeId not found in signed data");                                    continue;                                } else {                                    Node node = list.item(0);                                    String givenId = ((Text) node.getFirstChild()).getData();                                    if (!givenId.equals(pipeAd.getID().toString())) {                                        logger.debug("pipeId's didn't match!");                                        continue;                                    }                                }                            }                            // TODO: we should check if we actually trust this peer enough                            // ok, if we got here we're all OK                            logger.info("Adding pipe for service from peer " + peerAdv.getName());                            // TODO: use actual service space id (need signature verification)                            ServiceSpaceEndpoint endpoint = clientDAO.addPipeAdvertisement(1,pipeAd);                            knownPipeAds.put(pipeAd.getID(), endpoint);                        } catch (Exception e) {                            logger.debug("could not verify advertisement: " + e);                            continue;                        }                    }                } catch (Exception e) {