Skip to Content.
Sympa Menu

mace-opensaml-users - [OpenSAML] MalformedURLException: no protocol when unmarshalling assertion

Subject: OpenSAML user discussion

List archive

[OpenSAML] MalformedURLException: no protocol when unmarshalling assertion


Chronological Thread 
  • From: Bryce Allen <>
  • To: opensaml-users <>
  • Cc: Rachana Ananthakrishnan <>, Kyle Miller <>
  • Subject: [OpenSAML] MalformedURLException: no protocol when unmarshalling assertion
  • Date: Fri, 4 Mar 2011 16:05:09 -0600

I created an assertion using OpenSAML - see attached document. I am
marshalling and serializing the assertion to string like this:

public static String writeAssertionAsString(Assertion a) {
if (a == null)
throw new IllegalArgumentException("Passed assertion is
null");
try {
MarshallerFactory mf = Configuration.getMarshallerFactory();
Marshaller m = mf.getMarshaller(a);
if (m == null)
throw new IllegalArgumentException("marshaller is
null");

DocumentBuilderFactory dbfac =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbfac.newDocumentBuilder();

Document doc = docBuilder.newDocument();

m.marshall(a, doc);


// Transformation
TransformerFactory transfac =
TransformerFactory.newInstance();
Transformer trans = transfac.newTransformer();
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
"no");
trans.setOutputProperty(OutputKeys.METHOD,"xml");
//create string from xml tree
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
trans.transform(source, result);
return sw.toString();
} catch (MarshallingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}

And de-serializing/unmarshalling like this:

public static Assertion parseAssertion(String data)
throws SAXException, IOException, UnmarshallingException,
ParserConfigurationException {
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document document = builder.parse(data);
return parseAssertion(document);
}

public static Assertion parseAssertion(Document document)
throws UnmarshallingException {
Element element = document.getDocumentElement();
UnmarshallerFactory unmarshallerFactory =
Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller =
unmarshallerFactory.getUnmarshaller(element);
return (Assertion)unmarshaller.unmarshall(element);
}

I get the following exception from parseAssertion:

java.net.MalformedURLException: no protocol:
[entire XML document passed in]
at java.net.URL.<init>(URL.java:583)
at java.net.URL.<init>(URL.java:480)
at java.net.URL.<init>(URL.java:429)
at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source) at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at
org.apache.xerces.parsers.DOMParser.parse(Unknown Source) at
org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source) at
javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:177) at
org.cabig.rest.security.SAMLUtil.parseAssertion(SAMLUtil.java:234) at
org.cabig.rest.client.AssertionTester.main(AssertionTester.java:38)


I still get this error after changing my ID so it begins with a letter
(re the comment by Scott Cantor). What am I doing wrong here? Any help
would be greatly appreciated.

I can read the document and verify the signature fine without using
OpenSAML (i.e. using javax.xml.crypto.dsig). Using OpenSAML 2.4.1.

Thanks,
Bryce

Attachment: ballen.xml
Description: application/xml




Archive powered by MHonArc 2.6.16.

Top of Page