Skip to Content.
Sympa Menu

mace-opensaml-users - Getting UnsupportedOperationException while executing the call DefaultBootstrap.bootstrap()

Subject: OpenSAML user discussion

List archive

Getting UnsupportedOperationException while executing the call DefaultBootstrap.bootstrap()


Chronological Thread 
  • From:
  • To: <>
  • Cc: <>
  • Subject: Getting UnsupportedOperationException while executing the call DefaultBootstrap.bootstrap()
  • Date: Thu, 3 Apr 2008 03:50:58 -0400

Hi,

I am new to using OpenSAML2 library. I am trying to parse a sample SAML
response message. I am getting error while calling
DefaultBootstrap.bootstrap(): (source code attached)

Exception in thread "main" java.lang.UnsupportedOperationException: This
parser does not support specification "null" version "null"
at
javax.xml.parsers.DocumentBuilderFactory.setSchema(DocumentBuilderFactory.java:489)
at
org.opensaml.xml.parse.BasicParserPool.initializePool(BasicParserPool.java:498)
at
org.opensaml.xml.parse.BasicParserPool.<init>(BasicParserPool.java:144)
at org.opensaml.xml.XMLConfigurator.<init>(XMLConfigurator.java:70)
at
org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:131)
at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:75)
at com.hcl.fim.core.TestParser.<init>(TestParser.java:37)
at com.hcl.fim.core.TestParser.main(TestParser.java:80)

The exception seems it is raising during initialization of BasicParserpool.
Particular statement is :

newFactory.setSchema(schema); (BasicParserPool.java:498)

In constructor of BasicParserpool, we are initializing schema attribute of
BasicParserpool with null. But it is not accepting the null value. Please let
me know if you have anyidea on this.

Classpath while running the program:
E:/opensaml-2.0-rc3-bin/opensaml/dist/opensaml-trunk-jdk-1.5.jar;.;E:/opensaml-2.0-rc3-bin/opensaml/lib/bcprov-jdk14-138.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/commons-codec-1.3.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/commons-collections-3.1.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/commons-httpclient-3.1.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/commons-lang-2.1.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/jargs-1.0.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/jcl104-over-slf4j-1.5.0.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/joda-time-1.5.2.jar;E:/opensaml-2.0-
rc3-bin/opensaml/lib/not-yet-commons-ssl-0.3.9.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/openws-trunk-jdk-1.5.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/slf4j-api-1.5.0.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/velocity-1.5.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/xmlsec-1.4.1.jar;E:/opensaml-2.0-rc3-bin/opensaml/lib/xmltooling-trunk-jdk-1.5.jar;E:\opensaml-2.0-rc3-bin\opensaml\lib\slf4j-log4j12-1.5.0.jar;E:\opensaml-2.0-rc3-bin\opensaml\lib\log4j-1.2.12.jar

Thanks
Koteswararao.
import java.io.ByteArrayInputStream;

import org.opensaml.Configuration;
import org.opensaml.DefaultBootstrap;
import org.opensaml.saml2.core.Response;
import org.opensaml.xml.ConfigurationException;
import org.opensaml.xml.XMLObject;
import org.opensaml.xml.XMLObjectBuilderFactory;
import org.opensaml.xml.io.MarshallerFactory;
import org.opensaml.xml.io.Unmarshaller;
import org.opensaml.xml.io.UnmarshallerFactory;
import org.opensaml.xml.io.UnmarshallingException;
import org.opensaml.xml.parse.BasicParserPool;
import org.opensaml.xml.parse.XMLParserException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class TestParser {

/** Parser manager used to parse XML. */
protected static BasicParserPool parser;

/** XMLObject builder factory. */
protected static XMLObjectBuilderFactory builderFactory;

/** XMLObject marshaller factory. */
protected static MarshallerFactory marshallerFactory;

/** XMLObject unmarshaller factory. */
protected static UnmarshallerFactory unmarshallerFactory;

public TestParser() {

try {
DefaultBootstrap.bootstrap();
} catch (ConfigurationException x) {
System.out.println(x.getMessage());
}

parser = new BasicParserPool();
parser.setNamespaceAware(true);
builderFactory = Configuration.getBuilderFactory();
marshallerFactory = Configuration.getMarshallerFactory();
unmarshallerFactory = Configuration.getUnmarshallerFactory();
}

/**
* Unmarshalls an element file into its SAMLObject.
*
* @param samlMessageStr the string which contains SAMLMessage
*
* @return the SAMLObject from the file
*/
protected XMLObject unmarshallElement(String samlMessageStr) {
try {
Document doc = parser.parse(new ByteArrayInputStream(
samlMessageStr.getBytes()));
Element samlElement = doc.getDocumentElement();

Unmarshaller unmarshaller =
Configuration.getUnmarshallerFactory().getUnmarshaller(samlElement);
if (unmarshaller == null) {
System.out.println("Unable to retrieve unmarshaller by DOM
Element");
}

return unmarshaller.unmarshall(samlElement);
} catch (XMLParserException e) {
System.out.println("Unable to parse the element " +
samlMessageStr);
} catch (UnmarshallingException e) {
System.out.println("Unmarshalling failed when parsing element
" + samlMessageStr + ": " + e);
}

return null;
}

public static void main(String[] args) throws Exception {
String samlMessage = "<samlp:Response
xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"
xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"
Consent=\"urn:oasis:names:tc:SAML:2.0:consent:unspecified\"
Destination=\"http://localhost:7001/sso/ACS\";
ID=\"f7d5bb46d92a09984135ebc4d58c3406\" IssueInstant=\"2008-04-02T22:20:42Z\"
Version=\"2.0\"><saml:Issuer>http://localhost:7001/demo/idp</saml:Issuer><samlp:Status><samlp:StatusCode

Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\"></samlp:StatusCode></samlp:Status><saml:Assertion
ID=\"ac9ceedce6f198866991ca8d08c67fff\"
IssueInstant=\"2008-04-02T22:20:42Z\"
Version=\"2.0\"><saml:Issuer>http://localhost:7001/demo/idp</saml:Issuer><saml:Subject><saml:NameID
Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent\"
NameQualifier=\"http://localhost:7001/demo/idp\";
SPNameQualifier=\"http://localhost:7001/demo/sp\";>a7dc4d06b65824b9d2139226dbe85a00</saml:NameID><saml:SubjectConfirmation

Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"><saml:SubjectConfirmationData
NotOnOrAfter=\"2008-04-02T22:30:42Z\"
Recipient=\"http://rsactp82.rsafim1.com:7001/SSO/ACS\";></saml:SubjectConfirmationData></saml:SubjectConfirmation></saml:Subject><saml:Conditions
NotBefore=\"2008-04-02T22:15:42Z\"
NotOnOrAfter=\"2008-04-02T22:30:42Z\"><saml:AudienceRestriction><saml:Audience>http://localhost:7001/demo/sp</saml:Audience></saml:AudienceRestriction></saml:Conditions><saml:AuthnStatement
AuthnInstant=\"2008-04-02T22:20:00Z\"
SessionIndex=\"ac9ceedce6f198866991ca8d08c67fff\"><saml:SubjectLocality
Address=\"127.0.0.1\"
DNSName=\"127.0.0.1\"></saml:SubjectLocality><saml:AuthnContext><saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement></saml:Assertion></samlp:Response>";

Response response = (Response) new
TestParser().unmarshallElement(samlMessage);

if (response != null) {
System.out.println("Consent :" + response.getConsent());
System.out.println("Destination :" +
response.getDestination());
System.out.println("ID : " + response.getID());
System.out.println("InResponseTo :" +
response.getInResponseTo());
System.out.println("Signed :" + response.isSigned());
System.out.println("IssuerInstant :" +
response.getIssueInstant());
System.out.println("Issuer :" +
response.getIssuer().getValue());
}
}

}


Archive powered by MHonArc 2.6.16.

Top of Page