public static <T extends XMLObject> T transformSamlObject(final OpenSamlConfigBean configBean,
                                                              final byte[] data,
                                                              final Class<T> clazz) {
        if (data != null && data.length > 0) {
            try (val in = new ByteArrayInputStream(data)) {
                val document = configBean.getParserPool().parse(in);
                val root = document.getDocumentElement();
                val marshaller = configBean.getUnmarshallerFactory().getUnmarshaller(root);
                if (marshaller != null) {
                    val result = marshaller.unmarshall(root);
                    if (!clazz.isAssignableFrom(result.getClass())) {
                        throw new ClassCastException("Result [" + result + " is of type "
                                                     + result.getClass() + " when we were expecting " + clazz);
                    }
                    return (T) result;
                }
            } catch (final Exception e) {
                throw new SamlException(e.getMessage(), e);
            }
        }
        return null;
    }
Transform saml object t.

@param <T>        the type parameter
@param configBean the config bean
@param data       the data
@param clazz      the clazz
@return the type
support/cas-server-support-saml-core-api/src/main/java/org/apereo/cas/support/saml/SamlUtils.java