da_s_monk Awwwww! Good Job! | bon moi je te file une class java ke g creer:
elle recupere 1 xml de droit, et ensuite les nom des web service a appeler, ainsi qu'un autre xml contenant des info direct sur le user. dans le xml des droit (le premier) ca contient toute les methodes kil peut appeler. bon je sais ke c pas exactement ce ke tu cherche, mais je pense ke tu peux adapter (enfin j'espere). cette classe effectue une recherche xpath sur le xml et renvoies un boolean pour true ou false.:
Code :
- package IAMM.lib;
- import java.io.* ;
- import java.util.* ;
- import java.sql.*;
- import javax.servlet.* ;
- import javax.servlet.http.* ;
- import javax.sql.*;
- import org.apache.soap.* ;
- import org.apache.soap.encoding.soapenc.Base64;
- import org.apache.soap.rpc.* ;
- import org.apache.soap.server.* ;
- import org.apache.soap.server.http.* ;
- import org.apache.soap.util.* ;
- import org.apache.soap.rpc.SOAPContext;
- import org.apache.soap.util.xml.QName;
- import org.apache.xerces.parsers.DOMParser;
- import org.w3c.dom.*;
- import org.xml.sax.*;
- import org.apache.xpath.XPathAPI;
- public class rulesCheck{
- Document docRules;
- public String createXpath(String xmlContext, String service, String method) {
- Document tmp = createDomXml(xmlContext);
- Element rootContext = (Element)tmp.getDocumentElement();
- NamedNodeMap map = rootContext.getAttributes();
- String xpathString = "//CONTEXT[";
- int i;
- for (i = 0 ;i < map.getLength() ; i++){
- xpathString += "@" + map.item(i).getNodeName() + "=\"" + map.item(i).getNodeValue() + "\" and ";
- }
- xpathString += "@URI=\"" + service + "\" and @METHOD_NAME=\"" + method + "\"]";
- return xpathString;
- }
- public rulesCheck(String xmlRules){
- docRules = createDomXml(xmlRules);
- }
- /*creation dom xml (IAMM context (rules user) */
- public Document createDomXml(String xml){
- Document doc = null;
- try {
- DOMParser parser = new DOMParser();
- parser.parse(new InputSource(new StringReader(xml)));
- doc = parser.getDocument();
- }
- catch (SAXException e) {
- System.out.println(e.getMessage());
- }
- catch (IOException e) {
- System.out.println(e.getMessage());
- }
- return doc;
- }
- /*search context use xpath query*/
- public boolean searchContext(Document doc, String xpathString){
- Node result = null;
- try{
- Element root = (Element)doc.getDocumentElement();
- XPathAPI xpath = new XPathAPI();
- Node node = (Node)root;
- result = xpath.selectSingleNode(node, xpathString);
- if(result == null) return false;
- else return true;
- }
- catch (Exception e){
- return false;
- }
- }
- public boolean Check(String uri, String meth, String xmlContext){
- String xpath = createXpath(xmlContext, uri, meth);
- boolean result = searchContext(docRules, xpath);
- return result;
- }
- }
|
voila je te file aussi l'appel de la classe (c du jsp) que t l'integralité du truc:
Code :
- <%@ page import="IAMM.lib.rulesCheck" %>
- <%
- rulesCheck a = new rulesCheck(xmlcontext);
- boolean cr = a.Check("urn:IAMMAdminService","createAccounts",cnt);
- %>
|
cnt c le xml ki contient les info vite fait sur le user (endroit ou il se trouve)
ca risque de pas trop pouvoir t'aider, parceque g fait ca pour une application bien precise.
aller bonne chance et si t'arrive a faire en php, post le code
|