for (Enumeration methods = serviceInfo.enumerateServiceMethod(); e.hasMoreElements();) { ServiceMethod method = (ServiceMethod) e.nextElement();
for (Enumeration methods = serviceInfo.enumerateServiceMethod(); methods.hasMoreElements();) { ServiceMethod method = (ServiceMethod) methods.nextElement();
    public String verifyTreaty(String signedTreatyXMLDoc)            throws SecurityManagerException {        try {            // TODO: if necessary decrypt, and verify treaty document.            // from the verification we get the service space id            String treatyDoc = signedTreatyXMLDoc;            int requesterId = 100;            // first we need to make a Treaty instance object from the treaty document...            StringReader reader = new StringReader(treatyDoc);            Treaty treaty = Treaty.unmarshal(reader);            reader.close();            // now, for each service in the treaty, we get the authorized methods, and set            // the authorized flag for each method accordingly            ServiceInvokationPermissionDAO dao = new ServiceInvokationPermissionDAO(ds);            for (Enumeration e = treaty.enumerateServiceInfo(); e.hasMoreElements();) {                ServiceInfo serviceInfo = (ServiceInfo) e.nextElement();                ServiceInvokationPermission permission = dao.getPermissions(requesterId, serviceInfo.getServiceName());                for (Enumeration methods = serviceInfo.enumerateServiceMethod(); e.hasMoreElements();) {                    ServiceMethod method = (ServiceMethod) e.nextElement();                    MethodPermission mp = permission.getMethod(method.getMethodName());                    if (mp == null) {                        // method was not found in the permissions, set authorized to false                        method.setAuthorized(false);                    } else if (!mp.getParams().containsAll(Arrays.asList(method.getParameter()))) {                        // permission did not contain all the params that are requested in the method                        method.setAuthorized(false);                    } else {                        method.setAuthorized(true);                    }                    method.setNumInvokations(method.getNumInvokations());                }            }            // now, assign the treaty an id number and store in the database            treaty.setTreatyID(random.nextInt());            treatyDAO.addTreaty(treaty);            // finally, return the treaty inside a SecurityManagerResponse XML document            StringWriter writer = new StringWriter();            treaty.marshal(writer);            writer.close();            SecurityManagerResponse response = new SecurityManagerResponse();            response.setStatus(STATUS_OK);            response.setContent(writer.toString());            writer = new StringWriter();            response.marshal(writer);            writer.close();            return writer.toString();        } catch (Exception e) {            SecurityManagerResponse response = new SecurityManagerResponse();            response.setStatus(STATUS_ERROR);            response.setMessage(e.toString());            StringWriter writer = new StringWriter();            try {                response.marshal(writer);                writer.close();            } catch (Exception e2) {                throw new SecurityManagerException(e2);            }            return writer.toString();        }    }