Currently, I'm having issues with OpenSAML related to Java 17 Jakarta namespace issues. Right now I'm not able to use SAMLSchemaBuilder class object because when I get the Schema object, it's based on javax.xml.validation.Schema and not Jakarta namespace.
I'm using Apache WSS4J version 3.0.3 which uses OpenSAML 4.3.0 (though I really need WSS4J 4.x version for OpenSAML 5.1.3 but it's not released yet)
This is the code that I'm trying to get working.
SAMLSchemaBuilder schemaBuilder = new SAMLSchemaBuilder(SAML1Version.SAML_11);
Schema samlSchema = schemaBuilder.getSAMLSchema();
ValidatorFactory factory = samlSchema.newValidator(); // ERROR
The error is Type mismatch: cannot convert from javax.xml.validation.Validator to jakarta.validation.Validator
which makes sense because it's using javax namespace when I need jakarta. I looking for OpenSAML with Jakarta support and I see nothing. So I'm confused on why there isn't a Jakarta supported build out there.
I could write it like this but it won't be use SAML 1.1 validator and will be a pointless validator.
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
If anyone can help, let me know.
Instead of using the validator, I resolved what I needed to by taking this approach to validate SAML 1.1 version.
UnmarshallerFactory unmarshallerFactory =
XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
XMLObject xmlObject = unmarshaller.unmarshall(element);
if (xmlObject == null || !(xmlObject instanceof org.opensaml.saml.saml1.core.Assertion)) {
return false;
}