Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAML marshalling opensaml and java

I have recently upgraded opensaml dependency from 2.5.3 to 2.6.1 and xmlutil from 1.3.0 to 1.4.1. It compiles without any errors but while running the application i get the following exception:

java.lang.NullPointerException
org.opensaml.xml.io.AbstractXMLObjectMarshaller.marshall(AbstractXMLObjectMarshaller.java:84)

Calling Code:

final MarshallerFactory marshallerFac = SAMLUtil.getMarshallerFactory();
     final org.opensaml.xml.io.Marshaller authnStatementMarshaller = marshallerFac.getMarshaller(assertion);

     Element assertionElement = null;

     try {
        assertionElement = authnStatementMarshaller.marshall(assertion);
        try {
           // Sign assertion and query signature
           Signer.signObject(signature);
        }
        catch (final SignatureException e) {
           LOGGER.error("Fout opgetreden bij ondertekenen Assertion", e);
        }
     }
like image 386
avinash chavan Avatar asked Apr 25 '26 09:04

avinash chavan


1 Answers

I've noticed that if you don't initialize ("bootstrap") the SAML configuration, you get a NullPointerException (rather unhelpfully, I might add) when you try to construct the SAML.

import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;

try {
    DefaultBootstrap.bootstrap();
}
catch (ConfigurationException ce) {
}

The above is just a snippet of code to illustrate what I'm talking about. Did you maybe forget to bootstrap the configuration? That has to be done before you do anything.

like image 149
Mario Avatar answered Apr 27 '26 21:04

Mario