You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by Raul Benito <ra...@gmail.com> on 2005/02/08 22:25:56 UTC

Re: [jira] Assigned: (XMLBEANS-93) Default behavior of Factory.parse (or set )

Regarding the xml-security, I have recently use this and it works(so
perhaps the bug is already fixed):

----------------
String signagture="<Assertion
AssertionID=\"932aa4da-9aeb-484e-8ecf-99b4609c48f6\" Id=\"1\"
IssueInstant=\"2004-11-18T05:26:26Z\"
Issuer=\"DC=org,DC=DOEGrids,OU=Certificate Authorities,CN=DOEGrids CA
1\" MajorVersion=\"1\" MinorVersion=\"0\"
xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\">" +
                "<Conditions NotBefore=\"2004-11-18T05:26:26Z\"
NotOnOrAfter=\"2004-11-18T05:28:06Z\"/>" +
                "<AuthorizationDecisionStatement Decision=\"Permit\"
Resource=\"FTPNamespace|ftp://sample1.org\"
xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\">" +
                "<Subject xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\">" +
                "<NameIdentifier Format=\"#X509SubjectName\"
NameQualifier=\"dummyDN\">dummy DN</NameIdentifier>" +
                "<SubjectConfirmation>" +
               
"<ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:am:X509-PKI</ConfirmationMethod>"
+
                "</SubjectConfirmation></Subject>" +
                "<Action Namespace=\"fileType\"
xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\">read</Action><Action
Namespace=\"directory\"
xmlns=\"urn:oasis:names:tc:SAML:1.0:assertion\">read</Action></AuthorizationDecisionStatement>"+
        "</Assertion>\n";                
		final AssertionDocument a=AssertionDocument.Factory.parse(new
ByteArrayInputStream(signagture.getBytes()));
        Init.init();
        XMLSignature sig=new
XMLSignature(a.getAssertion().getDomNode().getOwnerDocument(),"","http://www.w3.org/2000/09/xmldsig#rsa-sha1");
        org.apache.xml.security.transforms.Transforms trs=new
org.apache.xml.security.transforms.Transforms(a.getAssertion().getDomNode().getOwnerDocument());
        trs.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);        
        sig.addDocument("#1",trs,Constants.ALGO_ID_DIGEST_SHA1);        
        sig.addResourceResolver(new ResourceResolverSpi(){
		public boolean engineCanResolve(Attr uri, String BaseURI) {
			// TODO Auto-generated method stub
			return true;
		}
            public XMLSignatureInput engineResolve(Attr uri, String BaseURI)
					throws ResourceResolverException {
				// TODO Auto-generated method stub
				return new XMLSignatureInput(a.getAssertion().getDomNode());
			}
            });
        ((Element)a.getAssertion().getDomNode()).appendChild(sig.getElement());
       KeyPair kp=KeyPairGenerator.getInstance("rsa").generateKeyPair();
        sig.addKeyInfo(kp.getPublic());
        sig.sign(kp.getPrivate());
        ByteArrayOutputStream os=new ByteArrayOutputStream();
        a.save(os);
        System.out.println(os.toString("UTF8"));
}
On Tue, 08 Feb 2005 10:00:22 +0100, Jean-Christophe Pazzaglia
<Je...@eurecom.fr> wrote:
> Thanks for looking at it,
> 
> I will try but I do not have time before the end of the week ,
> BTW is someone looking at issue 89 ... this is really a blocking
> issue for me, it is rather strange that I am the only one concerned
> by this issue ...
> 
> Thanks
> 
> jc
> 
> >     [ http://issues.apache.org/jira/browse/XMLBEANS-93?page=history ]
> >
> >Jacob Danner reassigned XMLBEANS-93:
> >------------------------------------
> >
> >    Assign To: Jacob Danner
> >
> >Can you verify this is still an issue in v2?
> >
> >
> >
> >>Default behavior of  Factory.parse (or set )
> >>--------------------------------------------
> >>
> >>         Key: XMLBEANS-93
> >>         URL: http://issues.apache.org/jira/browse/XMLBEANS-93
> >>     Project: XMLBeans
> >>        Type: Improvement
> >>  Components: XmlObject
> >>    Versions: Version 1.0.3
> >>    Reporter: jean-christophe.pazzaglia
> >>    Assignee: Jacob Danner
> >>    Priority: Minor
> >>
> >>
> >
> >
> >
> >>Dear XmlBeaner,
> >>I find the following behavior rather 'unnatural':
> >>if you do have a DOM element (likely to come from another library
> >>which doesnot use xmlbean) and you want to 'plug'-it with your
> >>XML-Bean structure it does not work 'out of the box' (even if the types
> >>are compatible !?!) and moreover produce non valid XML !
> >>It looks trivial:
> >>let's imagine that you want to add a signature (using xml-security):
> >>myXMLBean.setSignature( SignatureType.Factory.parse(sig.getElement())); // compile
> >>this will generate :
> >><myXMLBean>
> >><xd:Signature xmlns:xd="http://www.w3.org/2000/09/xmldsig#">
> >> <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
> >>...
> >></myXMLBean>
> >>while you expect :
> >><myXMLBean>
> >><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
> >>...
> >></myXMLBean>
> >>in order to make it you should use
> >>XmlOptions opts = new XmlOptions();
> >>opts.setLoadReplaceDocumentElement(null);
> >>myXMLBean.setSignature( SignatureType.Factory.parse(sig.getElement(),xmlopts));
> >>looks rather odd to me ...
> >>jc
> >>
> >>
> >
> >
> >
> 
> --
> Jean-Christophe.Pazzaglia@eurecom.fr
> Corporate communications
> Tel: (+33) 4-93-00-26-78
> PGP Key available : http://www.eurecom.fr/~pazzagli/publickey.pgp
> --
> Institut Eurécom - Office 029
> http://www.eurecom.fr/
> 2229 Route des CrĂȘtes
> BP 193
> 06904 Sophia Antipolis, France
> Fax: (+33) 4-93-00-26-27
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: dev-help@xmlbeans.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org