All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.gov.ida.saml.deserializers.OpenSamlXMLObjectUnmarshaller Maven / Gradle / Ivy

There is a newer version: 3.4.6-277
Show newest version
package uk.gov.ida.saml.deserializers;

import net.shibboleth.utilities.java.support.xml.XMLParserException;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.UnmarshallingException;
import uk.gov.ida.saml.core.validation.SamlTransformationErrorException;
import uk.gov.ida.saml.core.validation.SamlValidationSpecificationFailure;
import uk.gov.ida.saml.deserializers.parser.SamlObjectParser;

import static uk.gov.ida.saml.core.validation.errors.SamlTransformationErrorFactory.unableToDeserializeStringToOpenSaml;

public class OpenSamlXMLObjectUnmarshaller {

    private final SamlObjectParser samlObjectParser;

    public OpenSamlXMLObjectUnmarshaller(SamlObjectParser samlObjectParser) {
        this.samlObjectParser = samlObjectParser;
    }

    public TOutput fromString(String input) {
        try {
            return samlObjectParser.getSamlObject(input);
        } catch (UnmarshallingException | XMLParserException  e) {
            SamlValidationSpecificationFailure failure = unableToDeserializeStringToOpenSaml(input);
            throw new SamlTransformationErrorException(failure.getErrorMessage(), e, failure.getLogLevel());
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy