You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2023/10/20 13:42:50 UTC

[ws-wss4j] branch coheigea/saml-refactor updated: Adding ws-security-saml module

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch coheigea/saml-refactor
in repository https://gitbox.apache.org/repos/asf/ws-wss4j.git


The following commit(s) were added to refs/heads/coheigea/saml-refactor by this push:
     new 41903a2ef Adding ws-security-saml module
41903a2ef is described below

commit 41903a2ef36870e7918103cd935e8721a89fe074
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Fri Oct 20 14:42:37 2023 +0100

    Adding ws-security-saml module
---
 ws-security-saml/pom.xml                           |  202 ++++
 .../org/apache/wss4j/saml/OpenSAMLBootstrap.java   |  113 ++
 .../java/org/apache/wss4j/saml/OpenSAMLUtil.java   |  320 ++++++
 .../java/org/apache/wss4j/saml/SAMLCallback.java   |  412 ++++++++
 .../java/org/apache/wss4j/saml/SAMLKeyInfo.java    |   84 ++
 .../apache/wss4j/saml/SAMLKeyInfoProcessor.java    |   31 +
 .../main/java/org/apache/wss4j/saml/SAMLUtil.java  |  290 +++++
 .../apache/wss4j/saml/SamlAssertionWrapper.java    | 1113 ++++++++++++++++++++
 .../saml/WSS4JXSBase64BinaryUnmarshaller.java      |   47 +
 .../org/apache/wss4j/saml/bean/ActionBean.java     |  131 +++
 .../org/apache/wss4j/saml/bean/AdviceBean.java     |   96 ++
 .../org/apache/wss4j/saml/bean/AttributeBean.java  |  188 ++++
 .../wss4j/saml/bean/AttributeStatementBean.java    |  120 +++
 .../wss4j/saml/bean/AudienceRestrictionBean.java   |   99 ++
 .../wss4j/saml/bean/AuthDecisionStatementBean.java |  233 ++++
 .../saml/bean/AuthenticationStatementBean.java     |  226 ++++
 .../org/apache/wss4j/saml/bean/ConditionsBean.java |  289 +++++
 .../org/apache/wss4j/saml/bean/DelegateBean.java   |  121 +++
 .../org/apache/wss4j/saml/bean/KeyInfoBean.java    |  187 ++++
 .../org/apache/wss4j/saml/bean/NameIDBean.java     |  168 +++
 .../wss4j/saml/bean/ProxyRestrictionBean.java      |  105 ++
 .../org/apache/wss4j/saml/bean/SubjectBean.java    |  311 ++++++
 .../saml/bean/SubjectConfirmationDataBean.java     |  248 +++++
 .../wss4j/saml/bean/SubjectLocalityBean.java       |  137 +++
 .../java/org/apache/wss4j/saml/bean/Version.java   |   30 +
 .../wss4j/saml/builder/SAML1ComponentBuilder.java  |  626 +++++++++++
 .../apache/wss4j/saml/builder/SAML1Constants.java  |  147 +++
 .../wss4j/saml/builder/SAML2ComponentBuilder.java  |  891 ++++++++++++++++
 .../apache/wss4j/saml/builder/SAML2Constants.java  |  164 +++
 .../wss4j/saml/principal/SAMLTokenPrincipal.java   |   32 +
 .../saml/principal/SAMLTokenPrincipalImpl.java     |   59 ++
 .../wss4j/saml/processor/SAMLTokenProcessor.java   |  285 +++++
 .../src/main/resources/saml2-xacml2-profile.xml    |   76 ++
 .../src/main/resources/wss4j-signature-config.xml  |   15 +
 .../apache/wss4j/common/saml/OpenSAMLUtilTest.java |   37 +
 .../src/test/resources/log4j.properties            |   77 ++
 36 files changed, 7710 insertions(+)

diff --git a/ws-security-saml/pom.xml b/ws-security-saml/pom.xml
new file mode 100644
index 000000000..61f514e65
--- /dev/null
+++ b/ws-security-saml/pom.xml
@@ -0,0 +1,202 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.wss4j</groupId>
+        <artifactId>wss4j-parent</artifactId>
+        <relativePath>../parent/pom.xml</relativePath>
+        <version>4.0.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>wss4j-ws-security-saml</artifactId>
+    <name>Apache WSS4J WS-Security SAML</name>
+    
+    <properties>
+        <wss4j.osgi.import>
+            net.shibboleth*;resolution:=optional
+        </wss4j.osgi.import>
+       <wss4j.module.name>org.apache.wss4j.saml</wss4j.module.name>
+    </properties>
+    
+    <build>
+        <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
+        <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
+        <resources>
+            <resource>
+                <directory>src/main/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </resource>
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+        </resources>
+        <testResources>
+            <testResource>
+                <directory>src/test/java</directory>
+                <excludes>
+                    <exclude>**/*.java</exclude>
+                </excludes>
+            </testResource>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </testResource>
+        </testResources>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opensaml</groupId>
+            <artifactId>opensaml-saml-impl</artifactId>
+            <version>${opensaml.version}</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.opensaml</groupId>
+                    <artifactId>opensaml-soap-impl</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.opensaml</groupId>
+                    <artifactId>opensaml-storage-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.opensaml</groupId>
+                    <artifactId>opensaml-messaging-api</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.velocity</groupId>
+                    <artifactId>velocity-engine-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.httpcomponents</groupId>
+                    <artifactId>httpcore</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.httpcomponents</groupId>
+                    <artifactId>httpclient</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.google.code.findbugs</groupId>
+                    <artifactId>jsr305</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.google.guava</groupId>
+                    <artifactId>guava</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.cryptacular</groupId>
+                    <artifactId>cryptacular</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-core</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.cryptacular</groupId>
+            <artifactId>cryptacular</artifactId>
+            <version>${cryptacular.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>32.1.2-jre</version>
+            <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>com.google.guava</groupId>
+                    <artifactId>listenablefuture</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.google.code.findbugs</groupId>
+                    <artifactId>jsr305</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.google.errorprone</groupId>
+                    <artifactId>error_prone_annotations</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>com.google.j2objc</groupId>
+                    <artifactId>j2objc-annotations</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.checkerframework</groupId>
+                    <artifactId>checker-qual</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.codehaus.mojo</groupId>
+                    <artifactId>animal-sniffer-annotations</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.opensaml</groupId>
+            <artifactId>opensaml-xacml-impl</artifactId>
+            <version>${opensaml.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opensaml</groupId>
+            <artifactId>opensaml-xacml-saml-impl</artifactId>
+            <version>${opensaml.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.wss4j</groupId>
+            <artifactId>wss4j-ws-security-common</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-reload4j</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLBootstrap.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLBootstrap.java
new file mode 100644
index 000000000..f3858401c
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLBootstrap.java
@@ -0,0 +1,113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.opensaml.core.config.Configuration;
+import org.opensaml.core.xml.config.XMLConfigurationException;
+import org.opensaml.core.xml.config.XMLConfigurator;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+
+/**
+ * This class intializes the Opensaml library.
+ */
+public final class OpenSAMLBootstrap {
+
+    /** List of default configuration files. */
+    private static final String[] XML_CONFIGS = {
+        "/default-config.xml",
+        "/schema-config.xml",
+        "/saml1-assertion-config.xml",
+        "/saml1-metadata-config.xml",
+        "/saml1-protocol-config.xml",
+        "/saml2-assertion-config.xml",
+        "/saml2-assertion-delegation-restriction-config.xml",
+        "/saml2-ecp-config.xml",
+        "/saml2-metadata-algorithm-config.xml",
+        "/saml2-metadata-attr-config.xml",
+        "/saml2-metadata-config.xml",
+        "/saml2-metadata-idp-discovery-config.xml",
+        "/saml2-metadata-query-config.xml",
+        "/saml2-metadata-reqinit-config.xml",
+        "/saml2-metadata-ui-config.xml",
+        "/saml2-metadata-rpi-config.xml",
+        "/saml2-protocol-config.xml",
+        "/saml2-protocol-thirdparty-config.xml",
+        "/saml2-protocol-aslo-config.xml",
+        "/saml2-channel-binding-config.xml",
+        "/saml-ec-gss-config.xml",
+        "/signature-config.xml",
+        "/wss4j-signature-config.xml",  // Override the default Base64 Binary Unmarshaller for X.509 Certificates
+        "/encryption-config.xml",
+        "/xacml20-context-config.xml",
+        "/xacml20-policy-config.xml",
+        "/xacml10-saml2-profile-config.xml",
+        "/xacml11-saml2-profile-config.xml",
+        "/xacml2-saml2-profile-config.xml",
+        "/xacml3-saml2-profile-config.xml",
+        "/saml2-xacml2-profile.xml",
+    };
+
+    private OpenSAMLBootstrap() {
+        // complete
+    }
+
+    /**
+     * Initializes the OpenSAML library, loading default configurations.
+     *
+     * @throws XMLConfigurationException thrown if there is a problem initializing the OpenSAML library
+     */
+    public static synchronized void bootstrap() throws XMLConfigurationException {
+        bootstrap(true);
+    }
+
+    public static synchronized void bootstrap(boolean includeXacml) throws XMLConfigurationException {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        try {
+            XMLConfigurator configurator = new XMLConfigurator();
+
+            Thread.currentThread().setContextClassLoader(XMLObjectProviderRegistrySupport.class.getClassLoader());
+
+            for (String config : XML_CONFIGS) {
+                if (includeXacml || !config.contains("xacml")) {
+                    //most are found in the Configuration.class classloader
+                    InputStream ins = Configuration.class.getResourceAsStream(config);  //NOPMD
+                    if (ins == null) {
+                        //some are from us
+                        ins = OpenSAMLBootstrap.class.getResourceAsStream(config);
+                    }
+                    if (ins != null) {
+                        configurator.load(ins);
+                        try {
+                            ins.close();
+                        } catch (IOException ex) { //NOPMD
+                            // Do nothing
+                        }
+                    }
+                }
+            }
+        } finally {
+            Thread.currentThread().setContextClassLoader(loader);
+        }
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLUtil.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLUtil.java
new file mode 100644
index 000000000..0305686b6
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/OpenSAMLUtil.java
@@ -0,0 +1,320 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import javax.xml.namespace.QName;
+
+import net.shibboleth.shared.xml.impl.BasicParserPool;
+import net.shibboleth.shared.xml.ParserPool;
+
+import org.apache.wss4j.common.crypto.WSProviderConfig;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.opensaml.core.config.Configuration;
+import org.opensaml.core.config.ConfigurationService;
+import org.opensaml.core.config.provider.MapBasedConfiguration;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.XMLObjectBuilder;
+import org.opensaml.core.xml.XMLObjectBuilderFactory;
+import org.opensaml.core.xml.config.XMLConfigurationException;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.io.Marshaller;
+import org.opensaml.core.xml.io.MarshallerFactory;
+import org.opensaml.core.xml.io.MarshallingException;
+import org.opensaml.core.xml.io.Unmarshaller;
+import org.opensaml.core.xml.io.UnmarshallerFactory;
+import org.opensaml.core.xml.io.UnmarshallingException;
+import org.opensaml.saml.common.SignableSAMLObject;
+import org.opensaml.saml.config.SAMLConfiguration;
+import org.opensaml.xmlsec.config.DecryptionParserPool;
+import org.opensaml.xmlsec.signature.Signature;
+import org.opensaml.xmlsec.signature.support.SignatureException;
+import org.opensaml.xmlsec.signature.support.Signer;
+import org.opensaml.xmlsec.signature.support.SignerProvider;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+
+/**
+ * Class OpenSAMLUtil provides static helper methods for the OpenSaml library
+ */
+public final class OpenSAMLUtil {
+    private static final org.slf4j.Logger LOG =
+        org.slf4j.LoggerFactory.getLogger(OpenSAMLUtil.class);
+
+    private static XMLObjectProviderRegistry providerRegistry;
+    private static XMLObjectBuilderFactory builderFactory;
+    private static MarshallerFactory marshallerFactory;
+    private static UnmarshallerFactory unmarshallerFactory;
+    private static boolean samlEngineInitialized = false;
+
+    private OpenSAMLUtil() {
+        // Complete
+    }
+
+    /**
+     * Initialise the SAML library
+     */
+    public static synchronized void initSamlEngine() {
+        initSamlEngine(true);
+    }
+
+    public static synchronized void initSamlEngine(boolean includeXacml) {
+        if (!samlEngineInitialized) {
+            LOG.debug("Initializing the opensaml2 library...");
+            WSProviderConfig.init();
+
+            Configuration configuration = new MapBasedConfiguration();
+            ConfigurationService.setConfiguration(configuration);
+
+            providerRegistry = new XMLObjectProviderRegistry();
+            configuration.register(XMLObjectProviderRegistry.class, providerRegistry,
+                                   ConfigurationService.DEFAULT_PARTITION_NAME);
+
+            try {
+                OpenSAMLBootstrap.bootstrap(includeXacml);
+
+                SAMLConfiguration samlConfiguration = new SAMLConfiguration();
+
+                configuration.register(SAMLConfiguration.class, samlConfiguration,
+                                       ConfigurationService.DEFAULT_PARTITION_NAME);
+
+                builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
+                marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
+                unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
+
+                try {
+                    configureParserPool();
+
+                    // used by org.opensaml.saml.saml2.encryption.Decrypter
+                    configuration.register(DecryptionParserPool.class, new DecryptionParserPool(getParserPool()),
+                        ConfigurationService.DEFAULT_PARTITION_NAME);
+                } catch (Throwable t) {
+                    LOG.warn("Unable to bootstrap the parser pool part of the opensaml library "
+                             + "- some SAML operations may fail", t);
+                }
+
+                samlEngineInitialized = true;
+                LOG.debug("opensaml3 library bootstrap complete");
+            } catch (XMLConfigurationException ex) {
+                LOG.error("Unable to bootstrap the opensaml3 library - all SAML operations will fail", ex);
+            }
+        }
+    }
+
+    private static void configureParserPool() throws Throwable {
+        BasicParserPool pp = new BasicParserPool();
+        pp.setMaxPoolSize(50);
+        pp.initialize();
+        providerRegistry.setParserPool(pp);
+    }
+
+    /**
+     * Get the configured ParserPool.
+     *
+     * @return the configured ParserPool
+     */
+    public static ParserPool getParserPool() {
+        return providerRegistry.getParserPool();
+    }
+
+    /**
+     * Convert a SAML Assertion from a DOM Element to an XMLObject
+     *
+     * @param root of type Element
+     * @return XMLObject
+     * @throws WSSecurityException
+     */
+    public static XMLObject fromDom(Element root) throws WSSecurityException {
+        if (root == null) {
+            LOG.debug("Attempting to unmarshal a null element!");
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                                          new Object[] {"Error unmarshalling a SAML assertion"});
+        }
+        Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(root);
+        if (unmarshaller == null) {
+            LOG.debug("Unable to find an unmarshaller for element: " + root.getLocalName());
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                                          new Object[] {"Error unmarshalling a SAML assertion"});
+        }
+        try {
+            return unmarshaller.unmarshall(root);
+        } catch (UnmarshallingException ex) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                                          new Object[] {"Error unmarshalling a SAML assertion"});
+        }
+    }
+
+    /**
+     * Convert a SAML Assertion from a XMLObject to a DOM Element
+     *
+     * @param xmlObject of type XMLObject
+     * @param doc  of type Document
+     * @return Element
+     * @throws WSSecurityException
+     */
+    public static Element toDom(
+        XMLObject xmlObject,
+        Document doc
+    ) throws WSSecurityException {
+        return toDom(xmlObject, doc, true);
+    }
+
+    /**
+     * Convert a SAML Assertion from a XMLObject to a DOM Element
+     *
+     * @param xmlObject of type XMLObject
+     * @param doc  of type Document
+     * @param signObject whether to sign the XMLObject during marshalling
+     * @return Element
+     * @throws WSSecurityException
+     */
+    public static Element toDom(
+        XMLObject xmlObject,
+        Document doc,
+        boolean signObject
+    ) throws WSSecurityException {
+        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
+        Element element = null;
+        DocumentFragment frag = doc == null ? null : doc.createDocumentFragment();
+        try {
+            if (frag != null) {
+                while (doc.getFirstChild() != null) {
+                    frag.appendChild(doc.removeChild(doc.getFirstChild()));
+                }
+            }
+            try {
+                if (doc == null) {
+                    element = marshaller.marshall(xmlObject);
+                } else {
+                    element = marshaller.marshall(xmlObject, doc);
+                }
+            } catch (MarshallingException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                                              new Object[] {"Error marshalling a SAML assertion"});
+            }
+
+            if (signObject) {
+                signXMLObject(xmlObject);
+            }
+        } finally {
+            if (frag != null) {
+                while (doc.getFirstChild() != null) {
+                    doc.removeChild(doc.getFirstChild());
+                }
+                doc.appendChild(frag);
+            }
+        }
+        return element;
+    }
+
+    private static void signXMLObject(XMLObject xmlObject) throws WSSecurityException {
+        if (xmlObject instanceof org.opensaml.saml.saml1.core.Response) {
+            org.opensaml.saml.saml1.core.Response response =
+                    (org.opensaml.saml.saml1.core.Response)xmlObject;
+
+            // Sign any Assertions
+            if (response.getAssertions() != null) {
+                for (org.opensaml.saml.saml1.core.Assertion assertion : response.getAssertions()) {
+                    signObject(assertion.getSignature());
+                }
+            }
+
+            signObject(response.getSignature());
+        } else if (xmlObject instanceof org.opensaml.saml.saml2.core.Response) {
+            org.opensaml.saml.saml2.core.Response response =
+                    (org.opensaml.saml.saml2.core.Response)xmlObject;
+
+            // Sign any Assertions
+            if (response.getAssertions() != null) {
+                for (org.opensaml.saml.saml2.core.Assertion assertion : response.getAssertions()) {
+                    signObject(assertion.getSignature());
+                }
+            }
+
+            signObject(response.getSignature());
+        } else if (xmlObject instanceof SignableSAMLObject) {
+            signObject(((SignableSAMLObject)xmlObject).getSignature());
+        }
+    }
+
+    private static void signObject(Signature signature) throws WSSecurityException {
+        if (signature != null) {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(SignerProvider.class.getClassLoader());
+                Signer.signObject(signature);
+            } catch (SignatureException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                                              new Object[] {"Error signing a SAML assertion"});
+            } finally {
+                Thread.currentThread().setContextClassLoader(loader);
+            }
+        }
+    }
+
+    /**
+     * Method buildSignature ...
+     *
+     * @return Signature
+     */
+    @SuppressWarnings("unchecked")
+    public static Signature buildSignature() {
+        QName qName = Signature.DEFAULT_ELEMENT_NAME;
+        XMLObjectBuilder<Signature> builder =
+            (XMLObjectBuilder<Signature>)builderFactory.getBuilder(qName);
+        if (builder == null) {
+            LOG.error(
+                "Unable to retrieve builder for object QName "
+                + qName
+            );
+            return null;
+        }
+        return
+            builder.buildObject(
+                 qName.getNamespaceURI(), qName.getLocalPart(), qName.getPrefix()
+             );
+    }
+
+    /**
+     * Method isMethodSenderVouches ...
+     *
+     * @param confirmMethod of type String
+     * @return boolean
+     */
+    public static boolean isMethodSenderVouches(String confirmMethod) {
+        return
+            confirmMethod != null && confirmMethod.startsWith("urn:oasis:names:tc:SAML:")
+                && confirmMethod.endsWith(":cm:sender-vouches");
+    }
+
+    /**
+     * Method isMethodHolderOfKey ...
+     *
+     * @param confirmMethod of type String
+     * @return boolean
+     */
+    public static boolean isMethodHolderOfKey(String confirmMethod) {
+        return
+            confirmMethod != null && confirmMethod.startsWith("urn:oasis:names:tc:SAML:")
+                && confirmMethod.endsWith(":cm:holder-of-key");
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLCallback.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLCallback.java
new file mode 100644
index 000000000..b567ce915
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLCallback.java
@@ -0,0 +1,412 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import org.apache.wss4j.common.crypto.Crypto;
+import org.apache.wss4j.common.saml.bean.AdviceBean;
+import org.apache.wss4j.common.saml.bean.AttributeStatementBean;
+import org.apache.wss4j.common.saml.bean.AuthDecisionStatementBean;
+import org.apache.wss4j.common.saml.bean.AuthenticationStatementBean;
+import org.apache.wss4j.common.saml.bean.ConditionsBean;
+import org.apache.wss4j.common.saml.bean.SubjectBean;
+import org.apache.wss4j.common.saml.bean.Version;
+import org.opensaml.saml.common.SAMLVersion;
+import org.w3c.dom.Element;
+
+import javax.security.auth.callback.Callback;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Class SAMLCallback will be called by the <code>SamlAssertionWrapper</code> during the creation
+ * of SAML statements (authentication, attribute, and authz decision). Alternatively, the
+ * "assertionElement" member of this class can be set instead, for a pre-existing SAML
+ * Assertion.
+ */
+public class SAMLCallback implements Callback {
+
+    /**
+     * The SAML Version of the Assertion to create
+     */
+    private SAMLVersion samlVersion;
+
+    /**
+     * SAML subject representation
+     */
+    private SubjectBean subject;
+
+    /**
+     * The issuer of the Assertion
+     */
+    private String issuer;
+
+    /**
+     * The issuer format of the Assertion
+     */
+    private String issuerFormat;
+
+    /**
+     * The issuer qualifier of the Assertion
+     */
+    private String issuerQualifier;
+
+    /**
+     * SAML Conditions representation
+     */
+    private ConditionsBean conditions;
+
+    /**
+     * SAML Advice representation
+     */
+    private AdviceBean advice;
+
+    /**
+     * A list of <code>AuthenticationStatementBean</code> values
+     */
+    private List<AuthenticationStatementBean> authenticationStatementData;
+
+    /**
+     * A list of <code>AttributeStatementBean</code> values
+     */
+    private List<AttributeStatementBean> attributeStatementData;
+
+    /**
+     * A list of <code>AuthDecisionStatementBean</code> values
+     */
+    private List<AuthDecisionStatementBean> authDecisionStatementData;
+
+    /**
+     * A DOM Element representation of this SAML Assertion
+     */
+    private Element assertionElement;
+
+    private boolean signAssertion;
+
+    private String issuerKeyName;
+
+    private String issuerKeyPassword;
+
+    private Crypto issuerCrypto;
+
+    private boolean sendKeyValue;
+
+    private String canonicalizationAlgorithm;
+
+    private String signatureAlgorithm;
+
+    private String signatureDigestAlgorithm;
+
+    /**
+     * Constructor SAMLCallback creates a new SAMLCallback instance.
+     */
+    public SAMLCallback() {
+        authenticationStatementData = new ArrayList<>();
+        attributeStatementData = new ArrayList<>();
+        authDecisionStatementData = new ArrayList<>();
+    }
+
+    /**
+     * Method getAuthenticationStatementData returns the authenticationStatementData of this
+     * SAMLCallback object.
+     *
+     * @return the authenticationStatementData (type List<AuthenticationStatementBean>) of
+     *         this SAMLCallback object.
+     */
+    public List<AuthenticationStatementBean> getAuthenticationStatementData() {
+        return authenticationStatementData;
+    }
+
+    /**
+     * Method setAuthenticationStatementData sets the authenticationStatementData of this
+     * SAMLCallback object.
+     *
+     * @param authenticationStatementData the authenticationStatementData of this
+     *        SAMLCallback object.
+     */
+    public void setAuthenticationStatementData(
+        List<AuthenticationStatementBean> authenticationStatementData
+    ) {
+        this.authenticationStatementData = authenticationStatementData;
+    }
+
+    /**
+     * Method getAttributeStatementData returns the attributeStatementData of this
+     * SAMLCallback object.
+     *
+     * @return the attributeStatementData (type List<AttributeStatementBean>) of this
+     *         SAMLCallback object.
+     */
+    public List<AttributeStatementBean> getAttributeStatementData() {
+        return attributeStatementData;
+    }
+
+    /**
+     * Method setAttributeStatementData sets the attributeStatementData of this SAMLCallback object.
+     *
+     * @param attributeStatementData the attributeStatementData of this SAMLCallback object.
+     */
+    public void setAttributeStatementData(List<AttributeStatementBean> attributeStatementData) {
+        this.attributeStatementData = attributeStatementData;
+    }
+
+    /**
+     * Method getAuthDecisionStatementData returns the authDecisionStatementData of this
+     * SAMLCallback object.
+     *
+     * @return the authDecisionStatementData (type List<AuthDecisionStatementBean>) of this
+     *         SAMLCallback object.
+     */
+    public List<AuthDecisionStatementBean> getAuthDecisionStatementData() {
+        return authDecisionStatementData;
+    }
+
+    /**
+     * Method setAuthDecisionStatementData sets the authDecisionStatementData of this
+     * SAMLCallback object.
+     *
+     * @param authDecisionStatementData the authDecisionStatementData of this
+     *        SAMLCallback object.
+     */
+    public void setAuthDecisionStatementData(
+        List<AuthDecisionStatementBean> authDecisionStatementData
+    ) {
+        this.authDecisionStatementData = authDecisionStatementData;
+    }
+
+    /**
+     * Method getSubject returns the subject of this SAMLCallback object.
+     *
+     * @return the subject (type SubjectBean) of this SAMLCallback object.
+     */
+    public SubjectBean getSubject() {
+        if (subject != null) {
+            return subject;
+        }
+
+        // SAML 1.1 case
+        if (authenticationStatementData != null) {
+            for (AuthenticationStatementBean bean : authenticationStatementData) {
+                if (bean.getSubject() != null) {
+                    return bean.getSubject();
+                }
+            }
+        }
+
+        if (attributeStatementData != null) {
+            for (AttributeStatementBean bean : attributeStatementData) {
+                if (bean.getSubject() != null) {
+                    return bean.getSubject();
+                }
+            }
+        }
+
+        if (authDecisionStatementData != null) {
+            for (AuthDecisionStatementBean bean : authDecisionStatementData) {
+                if (bean.getSubject() != null) {
+                    return bean.getSubject();
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Method setSubject sets the subject of this SAMLCallback object.
+     *
+     * @param subject the subject of this SAMLCallback object.
+     */
+    public void setSubject(SubjectBean subject) {
+        this.subject = subject;
+    }
+
+    /**
+     * Method getIssuer returns the issuer of this SAMLCallback object.
+     *
+     * @return the issuer of this SAMLCallback object.
+     */
+    public String getIssuer() {
+        return issuer;
+    }
+
+    /**
+     * Method setIssuer sets the issuer of this SAMLCallback object.
+     *
+     * @param issuer the issuer of this SAMLCallback object.
+     */
+    public void setIssuer(String issuer) {
+        this.issuer = issuer;
+    }
+
+    /**
+     * Method getConditions returns the conditions of this SAMLCallback object.
+     *
+     * @return the conditions (type ConditionsBean) of this SAMLCallback object.
+     */
+    public ConditionsBean getConditions() {
+        return conditions;
+    }
+
+    /**
+     * Method setConditions sets the conditions of this SAMLCallback object.
+     *
+     * @param conditions the conditions of this SAMLCallback object.
+     */
+    public void setConditions(ConditionsBean conditions) {
+        this.conditions = conditions;
+    }
+
+    /**
+     * Set the SAMLVersion of the assertion to create
+     * @param samlVersion the SAMLVersion of the assertion to create
+     */
+    @Deprecated
+    public void setSamlVersion(SAMLVersion samlVersion) {
+        this.samlVersion = samlVersion;
+    }
+
+    /**
+     * Get the SAMLVersion of the assertion to create
+     * @return the SAMLVersion of the assertion to create
+     */
+    public SAMLVersion getSamlVersion() {
+        return samlVersion;
+    }
+
+    /**
+     * Set the SAML Version of the assertion to create
+     * @param samlVersion the SAML Version of the assertion to create
+     */
+    public void setSamlVersion(Version samlVersion) {
+        if (samlVersion == Version.SAML_20) {
+            this.samlVersion = SAMLVersion.VERSION_20;
+        } else if (samlVersion == Version.SAML_11) {
+            this.samlVersion = SAMLVersion.VERSION_11;
+        } else if (samlVersion == Version.SAML_10) {
+            this.samlVersion = SAMLVersion.VERSION_10;
+        }
+    }
+
+    /**
+     * Set the DOM representation of this SAML Assertion
+     * @param assertionElement the DOM representation of this SAML Assertion
+     */
+    public void setAssertionElement(Element assertionElement) {
+        this.assertionElement = assertionElement;
+    }
+
+    /**
+     * Get the DOM representation of this SAML Assertion
+     * @return the DOM representation of this SAML Assertion
+     */
+    public Element getAssertionElement() {
+        return assertionElement;
+    }
+
+    public boolean isSignAssertion() {
+        return signAssertion;
+    }
+
+    public void setSignAssertion(boolean signAssertion) {
+        this.signAssertion = signAssertion;
+    }
+
+    public String getIssuerKeyName() {
+        return issuerKeyName;
+    }
+
+    public void setIssuerKeyName(String issuerKeyName) {
+        this.issuerKeyName = issuerKeyName;
+    }
+
+    public String getIssuerKeyPassword() {
+        return issuerKeyPassword;
+    }
+
+    public void setIssuerKeyPassword(String issuerKeyPassword) {
+        this.issuerKeyPassword = issuerKeyPassword;
+    }
+
+    public Crypto getIssuerCrypto() {
+        return issuerCrypto;
+    }
+
+    public void setIssuerCrypto(Crypto issuerCrypto) {
+        this.issuerCrypto = issuerCrypto;
+    }
+
+    public boolean isSendKeyValue() {
+        return sendKeyValue;
+    }
+
+    public void setSendKeyValue(boolean sendKeyValue) {
+        this.sendKeyValue = sendKeyValue;
+    }
+
+    public String getCanonicalizationAlgorithm() {
+        return canonicalizationAlgorithm;
+    }
+
+    public void setCanonicalizationAlgorithm(String canonicalizationAlgorithm) {
+        this.canonicalizationAlgorithm = canonicalizationAlgorithm;
+    }
+
+    public String getSignatureAlgorithm() {
+        return signatureAlgorithm;
+    }
+
+    public void setSignatureAlgorithm(String signatureAlgorithm) {
+        this.signatureAlgorithm = signatureAlgorithm;
+    }
+
+    public String getSignatureDigestAlgorithm() {
+        return signatureDigestAlgorithm;
+    }
+
+    public void setSignatureDigestAlgorithm(String signatureDigestAlgorithm) {
+        this.signatureDigestAlgorithm = signatureDigestAlgorithm;
+    }
+
+    public AdviceBean getAdvice() {
+        return advice;
+    }
+
+    public void setAdvice(AdviceBean advice) {
+        this.advice = advice;
+    }
+
+    public String getIssuerFormat() {
+        return issuerFormat;
+    }
+
+    public void setIssuerFormat(String issuerFormat) {
+        this.issuerFormat = issuerFormat;
+    }
+
+    public String getIssuerQualifier() {
+        return issuerQualifier;
+    }
+
+    public void setIssuerQualifier(String issuerQualifier) {
+        this.issuerQualifier = issuerQualifier;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfo.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfo.java
new file mode 100644
index 000000000..9944cbc18
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfo.java
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+
+/**
+ * This holds key/cert information extracted from a SAML assertion
+ */
+public class SAMLKeyInfo {
+
+    /**
+     * Certificates
+     */
+    private X509Certificate[] certs;
+
+    /**
+     * Key bytes (e.g.: held in an encrypted key)
+     */
+    private byte[] secret;
+
+    /**
+     * The public key {e.g.: held in a ds:KeyInfo).
+     */
+    private PublicKey publicKey;
+
+    public SAMLKeyInfo() {
+    }
+
+    public SAMLKeyInfo(X509Certificate[] certs) {
+        this.certs = certs;
+    }
+
+    public SAMLKeyInfo(byte[] secret) {
+        this.secret = secret;
+    }
+
+    public SAMLKeyInfo(PublicKey publicKey) {
+        this.publicKey = publicKey;
+    }
+
+    public X509Certificate[] getCerts() {
+        return certs;
+    }
+
+    public void setCerts(X509Certificate[] certs) {
+        this.certs = certs;
+    }
+
+    public byte[] getSecret() {
+        return secret;
+    }
+
+    public void setSecret(byte[] secret) {
+        this.secret = secret;
+    }
+
+    public PublicKey getPublicKey() {
+        return this.publicKey;
+    }
+
+    public void setPublicKey(PublicKey publicKey) {
+        this.publicKey = publicKey;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfoProcessor.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfoProcessor.java
new file mode 100644
index 000000000..d2f1cc4bc
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLKeyInfoProcessor.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.w3c.dom.Element;
+
+/**
+ * This interface allows the user to plug in custom ways of processing a SAML KeyInfo.
+ */
+public interface SAMLKeyInfoProcessor {
+
+    SAMLKeyInfo processSAMLKeyInfo(Element keyInfoElement) throws WSSecurityException;
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLUtil.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLUtil.java
new file mode 100644
index 000000000..09a681550
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SAMLUtil.java
@@ -0,0 +1,290 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import java.io.IOException;
+import java.security.NoSuchProviderException;
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+import java.util.List;
+
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.xml.crypto.XMLStructure;
+import javax.xml.crypto.dom.DOMStructure;
+import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
+import javax.xml.crypto.dsig.keyinfo.KeyValue;
+import javax.xml.crypto.dsig.keyinfo.X509Data;
+import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
+
+import org.apache.wss4j.common.crypto.Crypto;
+import org.apache.wss4j.common.crypto.CryptoType;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.util.XMLUtils;
+import org.opensaml.saml.saml2.core.SubjectConfirmationData;
+import org.w3c.dom.Element;
+
+/**
+ * Utility methods for SAML stuff
+ */
+public final class SAMLUtil {
+
+    /**
+     * This constant defines the maximum amount of child elements of a Signature KeyInfo, associated with a
+     * signed SAML assertion. Any other child element will be ignored.
+     */
+    private static final int MAX_KEYINFO_CONTENT_LIST_SIZE = 3;
+
+    /**
+     * This constant defines the maximum amount of child elements of a X509Data KeyInfo, associated with a
+     * signed SAML assertion. Any other child element will be ignored.
+     */
+    private static final int MAX_X509DATA_SIZE = 5;
+
+    private static final String SIG_NS = "http://www.w3.org/2000/09/xmldsig#";
+
+    private SAMLUtil() {
+        // Complete
+    }
+
+    /**
+     * Parse a SAML Assertion to obtain a SAMLKeyInfo object from
+     * the Subject of the assertion
+     *
+     * @param samlAssertion The SAML Assertion
+     * @param keyInfoProcessor A pluggable way to parse the KeyInfo
+     * @return a SAMLKeyInfo object
+     * @throws WSSecurityException
+     */
+    public static SAMLKeyInfo getCredentialFromSubject(
+        SamlAssertionWrapper samlAssertion,
+        SAMLKeyInfoProcessor keyInfoProcessor,
+        Crypto sigCrypto
+    ) throws WSSecurityException {
+        if (samlAssertion.getSaml1() != null) {
+            return getCredentialFromSubject(
+                samlAssertion.getSaml1(), keyInfoProcessor, sigCrypto
+            );
+        } else if (samlAssertion.getSaml2() != null) {
+            return getCredentialFromSubject(
+                samlAssertion.getSaml2(), keyInfoProcessor, sigCrypto
+            );
+        }
+
+        throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                                      new Object[] {"Cannot get credentials from an unknown SAML Assertion"});
+    }
+
+    /**
+     * Get the SAMLKeyInfo object corresponding to the credential stored in the Subject of a
+     * SAML 1.1 assertion
+     * @param assertion The SAML 1.1 assertion
+     * @param keyInfoProcessor A pluggable way to parse the KeyInfo
+     * @param sigCrypto A Crypto instance
+     * @return The SAMLKeyInfo object obtained from the Subject
+     * @throws WSSecurityException
+     */
+    public static SAMLKeyInfo getCredentialFromSubject(
+        org.opensaml.saml.saml1.core.Assertion assertion,
+        SAMLKeyInfoProcessor keyInfoProcessor,
+        Crypto sigCrypto
+    ) throws WSSecurityException {
+        for (org.opensaml.saml.saml1.core.Statement stmt : assertion.getStatements()) {
+            org.opensaml.saml.saml1.core.Subject samlSubject = null;
+            if (stmt instanceof org.opensaml.saml.saml1.core.AttributeStatement) {
+                org.opensaml.saml.saml1.core.AttributeStatement attrStmt =
+                    (org.opensaml.saml.saml1.core.AttributeStatement) stmt;
+                samlSubject = attrStmt.getSubject();
+            } else if (stmt instanceof org.opensaml.saml.saml1.core.AuthenticationStatement) {
+                org.opensaml.saml.saml1.core.AuthenticationStatement authStmt =
+                    (org.opensaml.saml.saml1.core.AuthenticationStatement) stmt;
+                samlSubject = authStmt.getSubject();
+            } else {
+                org.opensaml.saml.saml1.core.AuthorizationDecisionStatement authzStmt =
+                    (org.opensaml.saml.saml1.core.AuthorizationDecisionStatement)stmt;
+                samlSubject = authzStmt.getSubject();
+            }
+
+            if (samlSubject != null && samlSubject.getSubjectConfirmation() != null) {
+                Element sub = samlSubject.getSubjectConfirmation().getDOM();
+                Element keyInfoElement =
+                    XMLUtils.getDirectChildElement(sub, "KeyInfo", SIG_NS);
+                if (keyInfoElement != null) {
+                    return getCredentialFromKeyInfo(
+                        keyInfoElement, keyInfoProcessor, sigCrypto
+                    );
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Get the SAMLKeyInfo object corresponding to the credential stored in the Subject of a
+     * SAML 2 assertion
+     * @param assertion The SAML 2 assertion
+     * @param keyInfoProcessor A pluggable way to parse the KeyInfo
+     * @param sigCrypto A Crypto instance
+     * @return The SAMLKeyInfo object obtained from the Subject
+     * @throws WSSecurityException
+     */
+    public static SAMLKeyInfo getCredentialFromSubject(
+        org.opensaml.saml.saml2.core.Assertion assertion,
+        SAMLKeyInfoProcessor keyInfoProcessor,
+        Crypto sigCrypto
+    ) throws WSSecurityException {
+        org.opensaml.saml.saml2.core.Subject samlSubject = assertion.getSubject();
+        if (samlSubject != null) {
+            List<org.opensaml.saml.saml2.core.SubjectConfirmation> subjectConfList =
+                samlSubject.getSubjectConfirmations();
+            for (org.opensaml.saml.saml2.core.SubjectConfirmation subjectConfirmation : subjectConfList) {
+                SubjectConfirmationData subjConfData =
+                    subjectConfirmation.getSubjectConfirmationData();
+                if (subjConfData != null) {
+                    Element sub = subjConfData.getDOM();
+                    Element keyInfoElement =
+                        XMLUtils.getDirectChildElement(sub, "KeyInfo", SIG_NS);
+                    if (keyInfoElement != null) {
+                        return getCredentialFromKeyInfo(
+                            keyInfoElement, keyInfoProcessor, sigCrypto
+                        );
+                    }
+                }
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * This method returns a SAMLKeyInfo corresponding to the credential found in the
+     * KeyInfo (DOM Element) argument.
+     * @param keyInfoElement The KeyInfo as a DOM Element
+     * @param keyInfoProcessor A pluggable way to parse the KeyInfo
+     * @param sigCrypto A Crypto instance
+     * @return The credential (as a SAMLKeyInfo object)
+     * @throws WSSecurityException
+     */
+    public static SAMLKeyInfo getCredentialFromKeyInfo(
+        Element keyInfoElement,
+        SAMLKeyInfoProcessor keyInfoProcessor,
+        Crypto sigCrypto
+    ) throws WSSecurityException {
+        //
+        // First try to find an EncryptedKey, BinarySecret or a SecurityTokenReference via DOM
+        //
+        if (keyInfoProcessor != null) {
+            SAMLKeyInfo samlKeyInfo = keyInfoProcessor.processSAMLKeyInfo(keyInfoElement);
+            if (samlKeyInfo != null) {
+                return samlKeyInfo;
+            }
+        }
+
+        //
+        // Next marshal the KeyInfo DOM element into a javax KeyInfo object and get the
+        // (public key) credential
+        //
+        KeyInfoFactory keyInfoFactory = null;
+        try {
+            keyInfoFactory = KeyInfoFactory.getInstance("DOM", "ApacheXMLDSig");
+        } catch (NoSuchProviderException ex) {
+            keyInfoFactory = KeyInfoFactory.getInstance("DOM");
+        }
+        XMLStructure keyInfoStructure = new DOMStructure(keyInfoElement);
+
+        try {
+            javax.xml.crypto.dsig.keyinfo.KeyInfo keyInfo =
+                keyInfoFactory.unmarshalKeyInfo(keyInfoStructure);
+            List<?> list = keyInfo.getContent();
+
+            X509Certificate[] certs = null;
+            PublicKey publicKey = null;
+            for (int i = 0; i < list.size(); i++) {
+                // Put a hard bound on how many child elements there can be of KeyInfo
+                if (i >= MAX_KEYINFO_CONTENT_LIST_SIZE) {
+                    break;
+                }
+                XMLStructure xmlStructure = (XMLStructure) list.get(i);
+                if (xmlStructure instanceof KeyValue && publicKey == null) {
+                    publicKey = ((KeyValue)xmlStructure).getPublicKey();
+                } else if (xmlStructure instanceof X509Data) {
+                    List<?> x509Data = ((X509Data)xmlStructure).getContent();
+                    for (int j = 0; j < x509Data.size(); j++) {
+                        // Put a hard bound on how many child elements there can be of X509Data
+                        if (j >= MAX_X509DATA_SIZE || certs != null) {
+                            break;
+                        }
+                        Object x509obj = x509Data.get(j);
+                        if (x509obj instanceof X509Certificate) {
+                            certs = new X509Certificate[1];
+                            certs[0] = (X509Certificate)x509obj;
+                        } else if (x509obj instanceof X509IssuerSerial) {
+                            if (sigCrypto == null) {
+                                throw new WSSecurityException(
+                                    WSSecurityException.ErrorCode.FAILURE, "noSigCryptoFile"
+                                );
+                            }
+                            CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ISSUER_SERIAL);
+                            cryptoType.setIssuerSerial(
+                                ((X509IssuerSerial)x509obj).getIssuerName(),
+                                ((X509IssuerSerial)x509obj).getSerialNumber()
+                            );
+                            certs = sigCrypto.getX509Certificates(cryptoType);
+                            if (certs == null || certs.length < 1) {
+                                throw new WSSecurityException(
+                                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                                    new Object[] {"cannot get certificate or key"}
+                                );
+                            }
+                        }
+                    }
+                }
+            }
+
+            if (certs != null || publicKey != null) {
+                SAMLKeyInfo samlKeyInfo = new SAMLKeyInfo(certs);
+                samlKeyInfo.setPublicKey(publicKey);
+                return samlKeyInfo;
+            }
+        } catch (Exception ex) {
+            throw new WSSecurityException(
+                WSSecurityException.ErrorCode.FAILURE, ex, "invalidSAMLsecurity",
+                new Object[] {"cannot get certificate or key"}
+            );
+        }
+        return null;
+    }
+
+    public static void doSAMLCallback(
+        CallbackHandler callbackHandler, SAMLCallback callback
+    ) {
+        // Create a new SAMLCallback with all of the information from the properties file.
+        try {
+            // Get the SAML source data using the currently configured callback implementation.
+            callbackHandler.handle(new SAMLCallback[]{callback});
+        } catch (IOException | UnsupportedCallbackException e) {
+            throw new IllegalStateException(
+                "Error while creating SAML assertion wrapper", e
+            );
+        }
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/SamlAssertionWrapper.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SamlAssertionWrapper.java
new file mode 100644
index 000000000..e158570bb
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/SamlAssertionWrapper.java
@@ -0,0 +1,1113 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import java.security.PrivateKey;
+import java.security.cert.X509Certificate;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wss4j.common.crypto.Crypto;
+import org.apache.wss4j.common.crypto.CryptoType;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.saml.builder.SAML1ComponentBuilder;
+import org.apache.wss4j.common.saml.builder.SAML2ComponentBuilder;
+import org.apache.wss4j.common.util.DOM2Writer;
+import org.apache.wss4j.common.util.InetAddressUtils;
+import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.apache.xml.security.utils.XMLUtils;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.saml.common.SAMLObject;
+import org.opensaml.saml.common.SAMLObjectContentReference;
+import org.opensaml.saml.common.SAMLVersion;
+import org.opensaml.saml.common.SignableSAMLObject;
+import org.opensaml.saml.saml1.core.AttributeStatement;
+import org.opensaml.saml.saml1.core.AuthenticationStatement;
+import org.opensaml.saml.saml1.core.AuthorizationDecisionStatement;
+import org.opensaml.saml.saml1.core.ConfirmationMethod;
+import org.opensaml.saml.saml1.core.Statement;
+import org.opensaml.saml.saml1.core.Subject;
+import org.opensaml.saml.saml1.core.SubjectConfirmation;
+import org.opensaml.saml.saml1.core.SubjectStatement;
+import org.opensaml.saml.saml2.core.AuthnStatement;
+import org.opensaml.saml.saml2.core.AuthzDecisionStatement;
+import org.opensaml.saml.saml2.core.Issuer;
+import org.opensaml.saml.security.impl.SAMLSignatureProfileValidator;
+import org.opensaml.security.credential.BasicCredential;
+import org.opensaml.security.x509.BasicX509Credential;
+import org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory;
+import org.opensaml.xmlsec.signature.KeyInfo;
+import org.opensaml.xmlsec.signature.Signature;
+import org.opensaml.xmlsec.signature.support.SignatureConstants;
+import org.opensaml.xmlsec.signature.support.SignatureException;
+import org.opensaml.xmlsec.signature.support.SignatureValidator;
+import org.opensaml.xmlsec.signature.support.SignerProvider;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Class SamlAssertionWrapper can generate, sign, and validate both SAML v1.1
+ * and SAML v2.0 assertions.
+ */
+public class SamlAssertionWrapper {
+    /**
+     * Field LOG
+     */
+    private static final org.slf4j.Logger LOG =
+        org.slf4j.LoggerFactory.getLogger(SamlAssertionWrapper.class);
+
+    /**
+     * Raw SAML Object
+     */
+    private SAMLObject samlObject;
+
+    /**
+     * Which SAML specification to use (currently, only v1.1 and v2.0 are supported)
+     */
+    private SAMLVersion samlVersion;
+
+    /**
+     * The Assertion as a DOM element
+     */
+    private Element assertionElement;
+
+    /**
+     * The SAMLKeyInfo object associated with the Subject KeyInfo
+     */
+    private SAMLKeyInfo subjectKeyInfo;
+
+    /**
+     * The SAMLKeyInfo object associated with the Signature on the Assertion
+     */
+    private SAMLKeyInfo signatureKeyInfo;
+
+    /**
+     * Default Canonicalization algorithm used for signing.
+     */
+    private final String defaultCanonicalizationAlgorithm = SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
+
+    /**
+     * Default RSA Signature algorithm used for signing.
+     */
+    private final String defaultRSASignatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1;
+
+    /**
+     * Default DSA Signature algorithm used for signing.
+     */
+    private final String defaultDSASignatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_DSA;
+
+    /**
+     * Default ECDSA Signature algorithm used for signing.
+     */
+    private final String defaultECDSASignatureAlgorithm = SignatureConstants.ALGO_ID_SIGNATURE_ECDSA_SHA1;
+
+    /**
+     * Default Signature Digest algorithm
+     */
+    private final String defaultSignatureDigestAlgorithm = SignatureConstants.ALGO_ID_DIGEST_SHA1;
+
+    /**
+     * Whether this object was instantiated with a DOM Element or an XMLObject initially
+     */
+    private final boolean fromDOM;
+
+    /**
+     * Constructor SamlAssertionWrapper creates a new SamlAssertionWrapper instance.
+     *
+     * @param element of type Element
+     * @throws WSSecurityException
+     */
+    public SamlAssertionWrapper(Element element) throws WSSecurityException {
+        OpenSAMLUtil.initSamlEngine();
+
+        parseElement(element);
+        fromDOM = true;
+    }
+
+    /**
+     * Constructor SamlAssertionWrapper creates a new SamlAssertionWrapper instance.
+     * This is the primary constructor.  All other constructor calls should
+     * be routed to this method to ensure that the wrapper is initialized
+     * correctly.
+     *
+     * @param samlObject of type SAMLObject
+     */
+    public SamlAssertionWrapper(SAMLObject samlObject) throws WSSecurityException {
+        OpenSAMLUtil.initSamlEngine();
+
+        this.samlObject = samlObject;
+        if (samlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
+            samlVersion = SAMLVersion.VERSION_11;
+        } else if (samlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
+            samlVersion = SAMLVersion.VERSION_20;
+        } else {
+            LOG.error(
+                "SamlAssertionWrapper: found unexpected type "
+                + (samlObject != null ? samlObject.getClass().getName() : null)
+            );
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                                          new Object[] {"A SAML 2.0 or 1.1 Assertion can only be used with "
+                                                        + "SamlAssertionWrapper"});
+        }
+        fromDOM = false;
+    }
+
+    /**
+     * Constructor SamlAssertionWrapper creates a new SamlAssertionWrapper instance.
+     * This constructor is primarily called on the client side to initialize
+     * the wrapper from a configuration file. <br>
+     *
+     * @param samlCallback of type SAMLCallback
+     */
+    public SamlAssertionWrapper(SAMLCallback samlCallback) throws WSSecurityException {
+        OpenSAMLUtil.initSamlEngine();
+
+        if (samlCallback.getAssertionElement() != null) {
+            parseElement(samlCallback.getAssertionElement());
+            fromDOM = true;
+        } else {
+            // If not then parse the SAMLCallback object
+            parseCallback(samlCallback);
+            fromDOM = false;
+        }
+    }
+
+    /**
+     * Method getSaml1 returns the saml1 of this SamlAssertionWrapper object.
+     *
+     * @return the saml1 (type Assertion) of this SamlAssertionWrapper object.
+     */
+    public org.opensaml.saml.saml1.core.Assertion getSaml1() {
+        if (samlVersion == SAMLVersion.VERSION_11) {
+            return (org.opensaml.saml.saml1.core.Assertion)samlObject;
+        }
+        return null;
+    }
+
+    /**
+     * Method getSaml2 returns the saml2 of this SamlAssertionWrapper object.
+     *
+     * @return the saml2 (type Assertion) of this SamlAssertionWrapper object.
+     */
+    public org.opensaml.saml.saml2.core.Assertion getSaml2() {
+        if (samlVersion == SAMLVersion.VERSION_20) {
+            return (org.opensaml.saml.saml2.core.Assertion)samlObject;
+        }
+        return null;
+    }
+
+    /**
+     * Method isCreated returns the created of this SamlAssertionWrapper object.
+     *
+     * @return the created (type boolean) of this SamlAssertionWrapper object.
+     */
+    public boolean isCreated() {
+        return samlObject != null;
+    }
+
+
+    /**
+     * Create a DOM from the current XMLObject content. If the user-supplied doc is not null,
+     * reparent the returned Element so that it is compatible with the user-supplied document.
+     *
+     * @param doc of type Document
+     * @return Element
+     */
+    public Element toDOM(Document doc) throws WSSecurityException {
+        if (fromDOM && assertionElement != null) {
+            parseElement(assertionElement);
+            if (doc != null) {
+                return (Element)doc.importNode(assertionElement, true);
+            }
+            return assertionElement;
+        }
+        assertionElement = OpenSAMLUtil.toDom(samlObject, doc);
+        return assertionElement;
+    }
+
+    /**
+     * Method assertionToString ...
+     *
+     * @return String
+     */
+    public String assertionToString() throws WSSecurityException {
+        if (assertionElement == null) {
+            Element element = toDOM(null);
+            return DOM2Writer.nodeToString(element);
+        }
+        return DOM2Writer.nodeToString(assertionElement);
+    }
+
+    public Instant getNotBefore() {
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20)) {
+            return getSaml2().getConditions().getNotBefore();
+        } else {
+            return getSaml1().getConditions().getNotBefore();
+        }
+    }
+
+    public Instant getNotOnOrAfter() {
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20)) {
+            return getSaml2().getConditions().getNotOnOrAfter();
+        } else {
+            return getSaml1().getConditions().getNotOnOrAfter();
+        }
+    }
+
+    /**
+     * Method getId returns the id of this SamlAssertionWrapper object.
+     *
+     * @return the id (type String) of this SamlAssertionWrapper object.
+     */
+    public String getId() {
+        String id = null;
+        if (samlVersion == SAMLVersion.VERSION_20) {
+            id = ((org.opensaml.saml.saml2.core.Assertion)samlObject).getID();
+            if (id == null || id.length() == 0) {
+                LOG.error("SamlAssertionWrapper: ID was null, seeting a new ID value");
+                id = IDGenerator.generateID("_");
+                ((org.opensaml.saml.saml2.core.Assertion)samlObject).setID(id);
+            }
+        } else if (samlVersion == SAMLVersion.VERSION_11) {
+            id = ((org.opensaml.saml.saml1.core.Assertion)samlObject).getID();
+            if (id == null || id.length() == 0) {
+                LOG.error("SamlAssertionWrapper: ID was null, seeting a new ID value");
+                id = IDGenerator.generateID("_");
+                ((org.opensaml.saml.saml1.core.Assertion)samlObject).setID(id);
+            }
+        } else {
+            LOG.error("SamlAssertionWrapper: unable to return ID - no saml assertion object");
+        }
+        return id;
+    }
+
+    /**
+     * Method getIssuerString returns the issuerString of this SamlAssertionWrapper object.
+     *
+     * @return the issuerString (type String) of this SamlAssertionWrapper object.
+     */
+    public String getIssuerString() {
+        if (samlVersion == SAMLVersion.VERSION_20
+            && ((org.opensaml.saml.saml2.core.Assertion)samlObject).getIssuer() != null) {
+            return ((org.opensaml.saml.saml2.core.Assertion)samlObject).getIssuer().getValue();
+        } else if (samlVersion == SAMLVersion.VERSION_11
+            && ((org.opensaml.saml.saml1.core.Assertion)samlObject).getIssuer() != null) {
+            return ((org.opensaml.saml.saml1.core.Assertion)samlObject).getIssuer();
+        }
+        LOG.error(
+            "SamlAssertionWrapper: unable to return Issuer string - no saml assertion "
+            + "object or issuer is null"
+        );
+        return null;
+    }
+
+    /**
+     * Method getSubjectName returns the Subject name value
+     * @return the subjectName of this SamlAssertionWrapper object
+     */
+    public String getSubjectName() {
+        if (samlVersion == SAMLVersion.VERSION_20) {
+            org.opensaml.saml.saml2.core.Subject subject =
+                ((org.opensaml.saml.saml2.core.Assertion)samlObject).getSubject();
+            if (subject != null && subject.getNameID() != null) {
+                return subject.getNameID().getValue();
+            }
+        } else if (samlVersion == SAMLVersion.VERSION_11) {
+            Subject samlSubject = null;
+            for (Statement stmt : ((org.opensaml.saml.saml1.core.Assertion)samlObject).getStatements()) {
+                if (stmt instanceof AttributeStatement) {
+                    AttributeStatement attrStmt = (AttributeStatement) stmt;
+                    samlSubject = attrStmt.getSubject();
+                } else if (stmt instanceof AuthenticationStatement) {
+                    AuthenticationStatement authStmt = (AuthenticationStatement) stmt;
+                    samlSubject = authStmt.getSubject();
+                } else {
+                    AuthorizationDecisionStatement authzStmt =
+                        (AuthorizationDecisionStatement)stmt;
+                    samlSubject = authzStmt.getSubject();
+                }
+                if (samlSubject != null) {
+                    break;
+                }
+            }
+            if (samlSubject != null && samlSubject.getNameIdentifier() != null) {
+                return samlSubject.getNameIdentifier().getValue();
+            }
+        }
+        LOG.error(
+                "SamlAssertionWrapper: unable to return SubjectName - no saml assertion "
+                        + "object or subject is null"
+        );
+        return null;
+    }
+
+    /**
+     * Method getConfirmationMethods returns the confirmationMethods of this
+     * SamlAssertionWrapper object.
+     *
+     * @return the confirmationMethods of this SamlAssertionWrapper object.
+     */
+    public List<String> getConfirmationMethods() {
+        List<String> methods = new ArrayList<>();
+        if (samlVersion == SAMLVersion.VERSION_20) {
+            org.opensaml.saml.saml2.core.Subject subject =
+                ((org.opensaml.saml.saml2.core.Assertion)samlObject).getSubject();
+            List<org.opensaml.saml.saml2.core.SubjectConfirmation> confirmations =
+                subject.getSubjectConfirmations();
+            for (org.opensaml.saml.saml2.core.SubjectConfirmation confirmation : confirmations) {
+                methods.add(confirmation.getMethod());
+            }
+        } else if (samlVersion == SAMLVersion.VERSION_11) {
+            List<SubjectStatement> subjectStatements = new ArrayList<>();
+            org.opensaml.saml.saml1.core.Assertion saml1 =
+                (org.opensaml.saml.saml1.core.Assertion)samlObject;
+            subjectStatements.addAll(saml1.getSubjectStatements());
+            subjectStatements.addAll(saml1.getAuthenticationStatements());
+            subjectStatements.addAll(saml1.getAttributeStatements());
+            subjectStatements.addAll(saml1.getAuthorizationDecisionStatements());
+            for (SubjectStatement subjectStatement : subjectStatements) {
+                Subject subject = subjectStatement.getSubject();
+                if (subject != null) {
+                    SubjectConfirmation confirmation = subject.getSubjectConfirmation();
+                    if (confirmation != null) {
+                        XMLObject data = confirmation.getSubjectConfirmationData();
+                        if (data instanceof ConfirmationMethod) {
+                            ConfirmationMethod method = (ConfirmationMethod) data;
+                            methods.add(method.getURI());
+                        }
+                        List<ConfirmationMethod> confirmationMethods =
+                            confirmation.getConfirmationMethods();
+                        for (ConfirmationMethod confirmationMethod : confirmationMethods) {
+                            methods.add(confirmationMethod.getURI());
+                        }
+                    }
+                }
+            }
+        }
+        return methods;
+    }
+
+    /**
+     * Method isSigned returns the signed of this SamlAssertionWrapper object.
+     *
+     * @return the signed (type boolean) of this SamlAssertionWrapper object.
+     */
+    public boolean isSigned() {
+        return samlObject instanceof SignableSAMLObject
+            && (((SignableSAMLObject)samlObject).isSigned()
+                || ((SignableSAMLObject)samlObject).getSignature() != null);
+    }
+
+    /**
+     * Method setSignature sets the signature of this SamlAssertionWrapper object.
+     *
+     * @param signature the signature of this SamlAssertionWrapper object.
+     */
+    public void setSignature(Signature signature) {
+        setSignature(signature, defaultSignatureDigestAlgorithm);
+    }
+
+    /**
+     * Method setSignature sets the signature of this SamlAssertionWrapper object.
+     *
+     * @param signature the signature of this SamlAssertionWrapper object.
+     * @param signatureDigestAlgorithm the signature digest algorithm to use
+     */
+    public void setSignature(Signature signature, String signatureDigestAlgorithm) {
+        if (samlObject instanceof SignableSAMLObject) {
+            SignableSAMLObject signableObject = (SignableSAMLObject) samlObject;
+            signableObject.setSignature(signature);
+            String digestAlg = signatureDigestAlgorithm;
+            if (digestAlg == null) {
+                digestAlg = defaultSignatureDigestAlgorithm;
+            }
+            SAMLObjectContentReference contentRef =
+                (SAMLObjectContentReference)signature.getContentReferences().get(0);
+            contentRef.setDigestAlgorithm(digestAlg);
+            signableObject.releaseDOM();
+            signableObject.releaseChildrenDOM(true);
+        } else {
+            LOG.error("Attempt to sign an unsignable object " + samlObject.getClass().getName());
+        }
+    }
+
+    /**
+     * Create an enveloped signature on the assertion that has been created.
+     *
+     * @param issuerKeyName the Issuer KeyName to use with the issuerCrypto argument
+     * @param issuerKeyPassword the Issuer Password to use with the issuerCrypto argument
+     * @param issuerCrypto the Issuer Crypto instance
+     * @param sendKeyValue whether to send the key value or not
+     * @throws WSSecurityException
+     */
+    public void signAssertion(String issuerKeyName, String issuerKeyPassword,
+            Crypto issuerCrypto, boolean sendKeyValue)
+            throws WSSecurityException {
+
+        signAssertion(issuerKeyName, issuerKeyPassword, issuerCrypto,
+                sendKeyValue, defaultCanonicalizationAlgorithm,
+                null, defaultSignatureDigestAlgorithm);
+    }
+
+    /**
+     * Create an enveloped signature on the assertion that has been created.
+     *
+     * @param issuerKeyName the Issuer KeyName to use with the issuerCrypto argument
+     * @param issuerKeyPassword the Issuer Password to use with the issuerCrypto argument
+     * @param issuerCrypto the Issuer Crypto instance
+     * @param sendKeyValue whether to send the key value or not
+     * @param canonicalizationAlgorithm the canonicalization algorithm to be used for signing
+     * @param signatureAlgorithm the signature algorithm to be used for signing
+     * @throws WSSecurityException
+     */
+    public void signAssertion(String issuerKeyName, String issuerKeyPassword,
+            Crypto issuerCrypto, boolean sendKeyValue,
+            String canonicalizationAlgorithm, String signatureAlgorithm)
+            throws WSSecurityException {
+        signAssertion(issuerKeyName, issuerKeyPassword, issuerCrypto, sendKeyValue,
+                canonicalizationAlgorithm, signatureAlgorithm, defaultSignatureDigestAlgorithm);
+    }
+
+    /**
+     * Create an enveloped signature on the assertion that has been created.
+     *
+     * @param issuerKeyName the Issuer KeyName to use with the issuerCrypto argument
+     * @param issuerKeyPassword the Issuer Password to use with the issuerCrypto argument
+     * @param issuerCrypto the Issuer Crypto instance
+     * @param sendKeyValue whether to send the key value or not
+     * @param canonicalizationAlgorithm the canonicalization algorithm to be used for signing
+     * @param signatureAlgorithm the signature algorithm to be used for signing
+     * @param signatureDigestAlgorithm the signature Digest algorithm to use
+     * @throws WSSecurityException
+     */
+    public void signAssertion(String issuerKeyName, String issuerKeyPassword,
+            Crypto issuerCrypto, boolean sendKeyValue,
+            String canonicalizationAlgorithm, String signatureAlgorithm,
+            String signatureDigestAlgorithm)
+            throws WSSecurityException {
+        //
+        // Create the signature
+        //
+        Signature signature = OpenSAMLUtil.buildSignature();
+        String c14nAlgo = canonicalizationAlgorithm;
+        if (c14nAlgo == null) {
+            c14nAlgo = defaultCanonicalizationAlgorithm;
+        }
+        signature.setCanonicalizationAlgorithm(c14nAlgo);
+        LOG.debug("Using Canonicalization algorithm {}", c14nAlgo);
+
+        // prepare to sign the SAML token
+        CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
+        cryptoType.setAlias(issuerKeyName);
+        X509Certificate[] issuerCerts = null;
+        if (issuerCrypto != null) {
+            issuerCerts = issuerCrypto.getX509Certificates(cryptoType);
+        }
+        if (issuerCerts == null || issuerCerts.length == 0) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                new Object[] {"No issuer certs were found to sign the SAML Assertion using issuer name: "
+                                              + issuerKeyName});
+        }
+
+        String sigAlgo = signatureAlgorithm;
+        if (sigAlgo == null) {
+            sigAlgo = defaultRSASignatureAlgorithm;
+            String pubKeyAlgo = issuerCerts[0].getPublicKey().getAlgorithm();
+            LOG.debug("automatic sig algo detection: {}", pubKeyAlgo);
+            if (pubKeyAlgo.equalsIgnoreCase("DSA")) {
+                sigAlgo = defaultDSASignatureAlgorithm;
+            } else if (pubKeyAlgo.equalsIgnoreCase("EC")) {
+                sigAlgo = defaultECDSASignatureAlgorithm;
+            }
+        }
+        LOG.debug("Using Signature algorithm {}", sigAlgo);
+        PrivateKey privateKey;
+        try {
+            privateKey = issuerCrypto.getPrivateKey(issuerKeyName, issuerKeyPassword);
+        } catch (Exception ex) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex);
+        }
+        if (privateKey == null) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+                new Object[] {"No private key was found using issuer name: " + issuerKeyName});
+        }
+
+        signature.setSignatureAlgorithm(sigAlgo);
+
+        BasicX509Credential signingCredential =
+            new BasicX509Credential(issuerCerts[0], privateKey);
+
+        signature.setSigningCredential(signingCredential);
+
+        X509KeyInfoGeneratorFactory kiFactory = new X509KeyInfoGeneratorFactory();
+        if (sendKeyValue) {
+            kiFactory.setEmitPublicKeyValue(true);
+        } else {
+            kiFactory.setEmitEntityCertificate(true);
+        }
+        try {
+            KeyInfo keyInfo = kiFactory.newInstance().generate(signingCredential);
+            signature.setKeyInfo(keyInfo);
+        } catch (org.opensaml.security.SecurityException ex) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                new Object[] {"Error generating KeyInfo from signing credential"});
+        }
+
+        // add the signature to the assertion
+        setSignature(signature, signatureDigestAlgorithm);
+    }
+
+    /**
+     * Verify the signature of this assertion
+     *
+     * @throws WSSecurityException
+     */
+    public void verifySignature(
+        SAMLKeyInfoProcessor keyInfoProcessor, Crypto sigCrypto
+    ) throws WSSecurityException {
+        Signature sig = getSignature();
+        if (sig != null) {
+            KeyInfo keyInfo = sig.getKeyInfo();
+            if (keyInfo == null) {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"}
+                );
+            }
+            SAMLKeyInfo samlKeyInfo =
+                SAMLUtil.getCredentialFromKeyInfo(keyInfo.getDOM(), keyInfoProcessor, sigCrypto);
+            verifySignature(samlKeyInfo);
+        } else {
+            LOG.debug("SamlAssertionWrapper: no signature to validate");
+        }
+
+    }
+
+    /**
+     * Verify the signature of this assertion
+     *
+     * @throws WSSecurityException
+     */
+    public void verifySignature(SAMLKeyInfo samlKeyInfo) throws WSSecurityException {
+        Signature sig = getSignature();
+        if (sig != null) {
+            if (samlKeyInfo == null) {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"}
+                );
+            }
+
+            BasicCredential credential = null;
+            if (samlKeyInfo.getCerts() != null) {
+                credential = new BasicX509Credential(samlKeyInfo.getCerts()[0]);
+            } else if (samlKeyInfo.getPublicKey() != null) {
+                credential = new BasicCredential(samlKeyInfo.getPublicKey());
+            } else {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"}
+                );
+            }
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(SignerProvider.class.getClassLoader());
+                SignatureValidator.validate(sig, credential);
+            } catch (SignatureException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex,
+                        "empty", new Object[] {"SAML signature validation failed"});
+            } finally {
+                Thread.currentThread().setContextClassLoader(loader);
+            }
+            signatureKeyInfo = samlKeyInfo;
+        } else {
+            LOG.debug("SamlAssertionWrapper: no signature to validate");
+        }
+    }
+
+    /**
+     * Validate the signature of the Assertion against the Profile. This does not actually
+     * verify the signature itself (see the verifySignature method for this)
+     * @throws WSSecurityException
+     */
+    public void validateSignatureAgainstProfile() throws WSSecurityException {
+        Signature sig = getSignature();
+        if (sig != null) {
+            SAMLSignatureProfileValidator validator = new SAMLSignatureProfileValidator();
+            try {
+                validator.validate(sig);
+            } catch (SignatureException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex,
+                    "empty", new Object[] {"SAML signature validation failed"});
+            }
+        }
+    }
+
+    /**
+     * This method parses the KeyInfo of the Subject. It then stores the SAMLKeyInfo object that
+     * has been obtained for future processing.
+     * @throws WSSecurityException
+     */
+    public void parseSubject(
+        SAMLKeyInfoProcessor keyInfoProcessor,
+        Crypto sigCrypto
+    ) throws WSSecurityException {
+        if (samlVersion == SAMLVersion.VERSION_11) {
+            subjectKeyInfo =
+                SAMLUtil.getCredentialFromSubject(
+                    (org.opensaml.saml.saml1.core.Assertion)samlObject, keyInfoProcessor, sigCrypto
+                );
+        } else if (samlVersion == SAMLVersion.VERSION_20) {
+            subjectKeyInfo =
+                SAMLUtil.getCredentialFromSubject(
+                    (org.opensaml.saml.saml2.core.Assertion)samlObject, keyInfoProcessor, sigCrypto
+                );
+        }
+    }
+
+
+    /**
+     * Method getSamlVersion returns the samlVersion of this SamlAssertionWrapper object.
+     *
+     * @return the samlVersion (type SAMLVersion) of this SamlAssertionWrapper object.
+     */
+    public SAMLVersion getSamlVersion() {
+        if (samlVersion == null) {
+            // Try to set the version.
+            LOG.debug(
+                "The SAML version was null in getSamlVersion(). Recomputing SAML version...");
+            if (samlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
+                samlVersion = SAMLVersion.VERSION_11;
+            } else if (samlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
+                samlVersion = SAMLVersion.VERSION_20;
+            } else {
+                // We are only supporting SAML v1.1 or SAML v2.0 at this time.
+                throw new IllegalStateException(
+                    "Could not determine the SAML version number. Check your "
+                    + "configuration and try again."
+                );
+            }
+        }
+        return samlVersion;
+    }
+
+    /**
+     * Get the Assertion as a DOM Element.
+     * @return the assertion as a DOM Element
+     */
+    public Element getElement() {
+        return assertionElement;
+    }
+
+    /**
+     * Get the SAMLKeyInfo associated with the signature of the assertion
+     * @return the SAMLKeyInfo associated with the signature of the assertion
+     */
+    public SAMLKeyInfo getSignatureKeyInfo() {
+        return signatureKeyInfo;
+    }
+
+    /**
+     * Get the SAMLKeyInfo associated with the Subject KeyInfo
+     * @return the SAMLKeyInfo associated with the Subject KeyInfo
+     */
+    public SAMLKeyInfo getSubjectKeyInfo() {
+        return subjectKeyInfo;
+    }
+
+    /**
+     * Get the SignatureValue bytes of the signed SAML Assertion
+     * @return the SignatureValue bytes of the signed SAML Assertion
+     * @throws WSSecurityException
+     */
+    public byte[] getSignatureValue() throws WSSecurityException {
+        Signature sig = null;
+        if (samlObject instanceof SignableSAMLObject) {
+            sig = ((SignableSAMLObject)samlObject).getSignature();
+        }
+        if (sig != null) {
+            return getSignatureValue(sig);
+        }
+        return new byte[0];
+    }
+
+    private byte[] getSignatureValue(Signature signature) throws WSSecurityException {
+        Element signatureElement = signature.getDOM();
+
+        if (signatureElement != null) {
+            Element signedInfoElem = XMLUtils.getNextElement(signatureElement.getFirstChild());
+            if (signedInfoElem != null) {
+                Element signatureValueElement =
+                    XMLUtils.getNextElement(signedInfoElem.getNextSibling());
+                if (signatureValueElement != null) {
+                    String base64Input = XMLUtils.getFullTextChildrenFromNode(signatureValueElement);
+                    return XMLUtils.decode(base64Input);
+                }
+            }
+        }
+
+        return new byte[0];
+    }
+
+    public Signature getSignature() throws WSSecurityException {
+        if (samlObject instanceof SignableSAMLObject) {
+            return ((SignableSAMLObject)samlObject).getSignature();
+        }
+        return null;
+    }
+
+    public SAMLObject getSamlObject() {
+        return samlObject;
+    }
+
+    /**
+     * Check the Conditions of the Assertion.
+     */
+    public void checkConditions(int futureTTL) throws WSSecurityException {
+        Instant validFrom = null;
+        Instant validTill = null;
+
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20)
+            && getSaml2().getConditions() != null) {
+            validFrom = getSaml2().getConditions().getNotBefore();
+            validTill = getSaml2().getConditions().getNotOnOrAfter();
+        } else if (getSamlVersion().equals(SAMLVersion.VERSION_11)
+            && getSaml1().getConditions() != null) {
+            validFrom = getSaml1().getConditions().getNotBefore();
+            validTill = getSaml1().getConditions().getNotOnOrAfter();
+        }
+
+        if (validFrom != null) {
+            Instant currentTime = Instant.now();
+            currentTime = currentTime.plusSeconds(futureTTL);
+            if (validFrom.isAfter(currentTime)) {
+                LOG.warn("SAML Token condition (Not Before) not met");
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+            }
+        }
+
+        if (validTill != null && validTill.isBefore(Instant.now())) {
+            LOG.warn("SAML Token condition (Not On Or After) not met");
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+        }
+    }
+
+    /**
+     * Check the IssueInstant value of the Assertion.
+     */
+    public void checkIssueInstant(int futureTTL, int ttl) throws WSSecurityException {
+        Instant issueInstant = null;
+        Instant validTill = null;
+
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20)
+            && getSaml2().getConditions() != null) {
+            validTill = getSaml2().getConditions().getNotOnOrAfter();
+            issueInstant = getSaml2().getIssueInstant();
+        } else if (getSamlVersion().equals(SAMLVersion.VERSION_11)
+            && getSaml1().getConditions() != null) {
+            validTill = getSaml1().getConditions().getNotOnOrAfter();
+            issueInstant = getSaml1().getIssueInstant();
+        }
+
+        // Check the IssueInstant is not in the future, subject to the future TTL
+        if (issueInstant != null) {
+            Instant currentTime = Instant.now().plusSeconds(futureTTL);
+            if (issueInstant.isAfter(currentTime)) {
+                LOG.warn("SAML Token IssueInstant not met");
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+            }
+
+            // If there is no NotOnOrAfter, then impose a TTL on the IssueInstant.
+            if (validTill == null) {
+                currentTime = currentTime.minusSeconds(ttl);
+
+                if (issueInstant.isBefore(currentTime)) {
+                    LOG.warn("SAML Token IssueInstant not met. The assertion was created too long ago.");
+                    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+                }
+            }
+        }
+
+    }
+
+    /**
+     * Check the AudienceRestrictions of the Assertion
+     */
+    public void checkAudienceRestrictions(List<String> audienceRestrictions) throws WSSecurityException {
+        // Now check the audience restriction conditions
+        if (audienceRestrictions == null || audienceRestrictions.isEmpty()) {
+            return;
+        }
+
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20) && getSaml2().getConditions() != null) {
+            org.opensaml.saml.saml2.core.Conditions conditions = getSaml2().getConditions();
+            if (conditions != null && conditions.getAudienceRestrictions() != null
+                && !conditions.getAudienceRestrictions().isEmpty()) {
+                boolean foundAddress = false;
+                for (org.opensaml.saml.saml2.core.AudienceRestriction audienceRestriction
+                    : conditions.getAudienceRestrictions()) {
+                    if (audienceRestriction.getAudiences() != null) {
+                        List<org.opensaml.saml.saml2.core.Audience> audiences =
+                            audienceRestriction.getAudiences();
+                        for (org.opensaml.saml.saml2.core.Audience audience : audiences) {
+                            String audienceURI = audience.getURI();
+                            if (audienceRestrictions.contains(audienceURI)) {
+                                foundAddress = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if (!foundAddress) {
+                    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+                }
+            }
+        } else if (getSamlVersion().equals(SAMLVersion.VERSION_11) && getSaml1().getConditions() != null) {
+            org.opensaml.saml.saml1.core.Conditions conditions = getSaml1().getConditions();
+            if (conditions != null && conditions.getAudienceRestrictionConditions() != null
+                && !conditions.getAudienceRestrictionConditions().isEmpty()) {
+                boolean foundAddress = false;
+                for (org.opensaml.saml.saml1.core.AudienceRestrictionCondition audienceRestriction
+                    : conditions.getAudienceRestrictionConditions()) {
+                    if (audienceRestriction.getAudiences() != null) {
+                        List<org.opensaml.saml.saml1.core.Audience> audiences =
+                            audienceRestriction.getAudiences();
+                        for (org.opensaml.saml.saml1.core.Audience audience : audiences) {
+                            String audienceURI = audience.getURI();
+                            if (audienceRestrictions.contains(audienceURI)) {
+                                foundAddress = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+
+                if (!foundAddress) {
+                    throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+                }
+            }
+        }
+    }
+
+    /**
+     * Check the various attributes of the AuthnStatements of the assertion (if any)
+     */
+    public void checkAuthnStatements(int futureTTL) throws WSSecurityException {
+        if (getSamlVersion().equals(SAMLVersion.VERSION_20)
+            && getSaml2().getAuthnStatements() != null) {
+            List<AuthnStatement> authnStatements = getSaml2().getAuthnStatements();
+
+            for (AuthnStatement authnStatement : authnStatements) {
+                Instant authnInstant = authnStatement.getAuthnInstant();
+                Instant sessionNotOnOrAfter = authnStatement.getSessionNotOnOrAfter();
+                String subjectLocalityAddress = null;
+
+                if (authnStatement.getSubjectLocality() != null
+                    && authnStatement.getSubjectLocality().getAddress() != null) {
+                    subjectLocalityAddress = authnStatement.getSubjectLocality().getAddress();
+                }
+
+                validateAuthnStatement(authnInstant, sessionNotOnOrAfter,
+                                       subjectLocalityAddress, futureTTL);
+            }
+        } else if (getSamlVersion().equals(SAMLVersion.VERSION_11)
+            && getSaml1().getAuthenticationStatements() != null) {
+            List<AuthenticationStatement> authnStatements =
+                getSaml1().getAuthenticationStatements();
+
+            for (AuthenticationStatement authnStatement : authnStatements) {
+                Instant authnInstant = authnStatement.getAuthenticationInstant();
+                String subjectLocalityAddress = null;
+
+                if (authnStatement.getSubjectLocality() != null
+                    && authnStatement.getSubjectLocality().getIPAddress() != null) {
+                    subjectLocalityAddress = authnStatement.getSubjectLocality().getIPAddress();
+                }
+
+                validateAuthnStatement(authnInstant, null,
+                                       subjectLocalityAddress, futureTTL);
+            }
+        }
+    }
+
+    private void validateAuthnStatement(
+        Instant authnInstant, Instant sessionNotOnOrAfter, String subjectLocalityAddress,
+        int futureTTL
+    ) throws WSSecurityException {
+        // AuthnInstant in the future
+        Instant currentTime = Instant.now();
+        currentTime = currentTime.plusSeconds(futureTTL);
+        if (authnInstant.isAfter(currentTime)) {
+            LOG.warn("SAML Token AuthnInstant not met");
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+        }
+
+        // Stale SessionNotOnOrAfter
+        if (sessionNotOnOrAfter != null && sessionNotOnOrAfter.isBefore(Instant.now())) {
+            LOG.warn("SAML Token SessionNotOnOrAfter not met");
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+        }
+
+        // Check that the SubjectLocality address is an IP address
+        if (subjectLocalityAddress != null
+            && !(InetAddressUtils.isIPv4Address(subjectLocalityAddress)
+                || InetAddressUtils.isIPv6Address(subjectLocalityAddress))) {
+            LOG.warn("SAML Token SubjectLocality address is not valid: " + subjectLocalityAddress);
+            throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
+        }
+    }
+
+    /**
+     * Parse the DOM Element into Opensaml objects.
+     */
+    private void parseElement(Element element) throws WSSecurityException {
+        XMLObject xmlObject = OpenSAMLUtil.fromDom(element);
+        if (xmlObject instanceof org.opensaml.saml.saml1.core.Assertion) {
+            this.samlObject = (SAMLObject)xmlObject;
+            samlVersion = SAMLVersion.VERSION_11;
+        } else if (xmlObject instanceof org.opensaml.saml.saml2.core.Assertion) {
+            this.samlObject = (SAMLObject)xmlObject;
+            samlVersion = SAMLVersion.VERSION_20;
+        } else {
+            LOG.error(
+                "SamlAssertionWrapper: found unexpected type " + xmlObject.getClass().getName()
+            );
+        }
+
+        assertionElement = element;
+    }
+
+    /**
+     * Parse a SAMLCallback object to create a SAML Assertion
+     */
+    private void parseCallback(
+        SAMLCallback samlCallback
+    ) throws WSSecurityException {
+        samlVersion = samlCallback.getSamlVersion();
+        if (samlVersion == null) {
+            samlVersion = SAMLVersion.VERSION_20;
+        }
+        String issuer = samlCallback.getIssuer();
+        String issuerFormat = samlCallback.getIssuerFormat();
+        String issuerQualifier = samlCallback.getIssuerQualifier();
+
+        if (samlVersion.equals(SAMLVersion.VERSION_11)) {
+            // Build a SAML v1.1 assertion
+            org.opensaml.saml.saml1.core.Assertion saml1 =
+                SAML1ComponentBuilder.createSamlv1Assertion(issuer);
+
+            try {
+                // Process the SAML authentication statement(s)
+                List<AuthenticationStatement> authenticationStatements =
+                    SAML1ComponentBuilder.createSamlv1AuthenticationStatement(
+                        samlCallback.getAuthenticationStatementData()
+                    );
+                saml1.getAuthenticationStatements().addAll(authenticationStatements);
+
+                // Process the SAML attribute statement(s)
+                List<AttributeStatement> attributeStatements =
+                        SAML1ComponentBuilder.createSamlv1AttributeStatement(
+                            samlCallback.getAttributeStatementData()
+                        );
+                saml1.getAttributeStatements().addAll(attributeStatements);
+
+                // Process the SAML authorization decision statement(s)
+                List<AuthorizationDecisionStatement> authDecisionStatements =
+                        SAML1ComponentBuilder.createSamlv1AuthorizationDecisionStatement(
+                            samlCallback.getAuthDecisionStatementData()
+                        );
+                saml1.getAuthorizationDecisionStatements().addAll(authDecisionStatements);
+
+                // Build the complete assertion
+                org.opensaml.saml.saml1.core.Conditions conditions =
+                    SAML1ComponentBuilder.createSamlv1Conditions(samlCallback.getConditions());
+                saml1.setConditions(conditions);
+
+                if (samlCallback.getAdvice() != null) {
+                    org.opensaml.saml.saml1.core.Advice advice =
+                        SAML1ComponentBuilder.createAdvice(samlCallback.getAdvice());
+                    saml1.setAdvice(advice);
+                }
+            } catch (org.opensaml.security.SecurityException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                    new Object[] {"Error generating KeyInfo from signing credential"}
+                );
+            }
+
+            // Set the OpenSaml2 XMLObject instance
+            samlObject = saml1;
+
+        } else if (samlVersion.equals(SAMLVersion.VERSION_20)) {
+            // Build a SAML v2.0 assertion
+            org.opensaml.saml.saml2.core.Assertion saml2 = SAML2ComponentBuilder.createAssertion();
+            Issuer samlIssuer = SAML2ComponentBuilder.createIssuer(issuer, issuerFormat, issuerQualifier);
+
+            // Authn Statement(s)
+            List<AuthnStatement> authnStatements =
+                SAML2ComponentBuilder.createAuthnStatement(
+                    samlCallback.getAuthenticationStatementData()
+                );
+            saml2.getAuthnStatements().addAll(authnStatements);
+
+            // Attribute statement(s)
+            List<org.opensaml.saml.saml2.core.AttributeStatement> attributeStatements =
+                SAML2ComponentBuilder.createAttributeStatement(
+                    samlCallback.getAttributeStatementData()
+                );
+            saml2.getAttributeStatements().addAll(attributeStatements);
+
+            // AuthzDecisionStatement(s)
+            List<AuthzDecisionStatement> authDecisionStatements =
+                    SAML2ComponentBuilder.createAuthorizationDecisionStatement(
+                        samlCallback.getAuthDecisionStatementData()
+                    );
+            saml2.getAuthzDecisionStatements().addAll(authDecisionStatements);
+
+            // Build the SAML v2.0 assertion
+            saml2.setIssuer(samlIssuer);
+
+            try {
+                org.opensaml.saml.saml2.core.Subject subject =
+                    SAML2ComponentBuilder.createSaml2Subject(samlCallback.getSubject());
+                saml2.setSubject(subject);
+            } catch (org.opensaml.security.SecurityException ex) {
+                throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, ex, "empty",
+                    new Object[] {"Error generating KeyInfo from signing credential"}
+                );
+            }
+
+            org.opensaml.saml.saml2.core.Conditions conditions =
+                SAML2ComponentBuilder.createConditions(samlCallback.getConditions());
+            saml2.setConditions(conditions);
+
+            if (samlCallback.getAdvice() != null) {
+                org.opensaml.saml.saml2.core.Advice advice =
+                    SAML2ComponentBuilder.createAdvice(samlCallback.getAdvice());
+                saml2.setAdvice(advice);
+            }
+
+            // Set the OpenSaml2 XMLObject instance
+            samlObject = saml2;
+        }
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/WSS4JXSBase64BinaryUnmarshaller.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/WSS4JXSBase64BinaryUnmarshaller.java
new file mode 100644
index 000000000..8827d8145
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/WSS4JXSBase64BinaryUnmarshaller.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import net.shibboleth.utilities.java.support.primitive.StringSupport;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.io.UnmarshallingException;
+import org.w3c.dom.Text;
+
+/**
+ * Override the OpenSAML BASE-64 unmarshaller for X.509 Certificates, to fix a test failure in CXF due to the fact
+ * that an X.509 Certificate is only partially unmarshalled.
+ *
+ * https://issues.apache.org/jira/browse/WSS-695
+ */
+public final class WSS4JXSBase64BinaryUnmarshaller extends org.opensaml.core.xml.schema.impl.XSBase64BinaryUnmarshaller {
+
+    /**
+     * A fix to call Text.getWholeText() instead of Text.getData(), as otherwise with the SAMLRenewTest in CXF's STS
+     * systests, the X.509 Certificate is only partially unmarshalled.
+     */
+    @Override
+    protected void unmarshallTextContent(XMLObject xmlObject, Text content) throws UnmarshallingException {
+        final String textContent = StringSupport.trimOrNull(content.getWholeText());
+        if (textContent != null) {
+            processElementContent(xmlObject, textContent);
+        }
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ActionBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ActionBean.java
new file mode 100644
index 000000000..bc31163d3
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ActionBean.java
@@ -0,0 +1,131 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+
+/**
+ * Class SamlAction represents the raw data required by the <code>SamlAssertionWrapper</code> when
+ * creating the <code>Action</code> element of the SAML Authorization Decision Statement.
+ */
+public class ActionBean {
+
+    /**
+     * A URI reference representing the namespace in which the name of the specified action is to be
+     * interpreted. If this element is absent, the namespace
+     * urn:oasis:names:tc:SAML:1.0:action:rwedcnegation specified in Section 7.2.2 is in effect.
+     */
+    private String actionNamespace;
+
+    /**
+     * An action sought to be performed on the specified resource (i.e. Read, Write, Update, Delete)
+     */
+    private String contents;
+
+    /**
+     * Constructor SamlAction creates a new SamlAction instance.
+     */
+    public ActionBean() {
+    }
+
+    /**
+     * Constructor SamlAction creates a new SamlAction instance.
+     *
+     * @param actionNamespace of type String
+     * @param contents of type String
+     */
+    public ActionBean(String actionNamespace, String contents) {
+        this.actionNamespace = actionNamespace;
+        this.contents = contents;
+    }
+
+    /**
+     * Method getActionNamespace returns the actionNamespace of this SamlAction object.
+     *
+     * @return the actionNamespace (type String) of this SamlAction object.
+     */
+    public String getActionNamespace() {
+        return actionNamespace;
+    }
+
+    /**
+     * Method setActionNamespace sets the actionNamespace of this SamlAction object.
+     *
+     * @param actionNamespace the actionNamespace of this SamlAction object.
+     */
+    public void setActionNamespace(String actionNamespace) {
+        this.actionNamespace = actionNamespace;
+    }
+
+    /**
+     * Method getContents returns the contents of this SamlAction object.
+     *
+     * @return the contents (type String) of this SamlAction object.
+     */
+    public String getContents() {
+        return contents;
+    }
+
+    /**
+     * Method setContents sets the contents of this SamlAction object.
+     *
+     * @param contents the contents of this SamlAction object.
+     */
+    public void setContents(String contents) {
+        this.contents = contents;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof ActionBean)) {
+            return false;
+        }
+
+        ActionBean that = (ActionBean) o;
+
+        if (contents == null && that.contents != null) {
+            return false;
+        } else if (contents != null && !contents.equals(that.contents)) {
+            return false;
+        }
+
+        if (actionNamespace == null && that.actionNamespace != null) {
+            return false;
+        } else if (actionNamespace != null && !actionNamespace.equals(that.actionNamespace)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (contents != null) {
+            result = 31 * result + contents.hashCode();
+        }
+        if (actionNamespace != null) {
+            result = 31 * result + actionNamespace.hashCode();
+        }
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AdviceBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AdviceBean.java
new file mode 100644
index 000000000..5d10eec7a
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AdviceBean.java
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+
+/**
+ * Represents a SAML Advice Element.
+ */
+public class AdviceBean {
+
+    private List<String> idReferences = new ArrayList<>();
+    private List<String> uriReferences = new ArrayList<>();
+    private List<Element> assertions = new ArrayList<>();
+
+    public List<String> getIdReferences() {
+        return idReferences;
+    }
+
+    public List<String> getUriReferences() {
+        return uriReferences;
+    }
+
+    public List<Element> getAssertions() {
+        return assertions;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AdviceBean)) {
+            return false;
+        }
+
+        AdviceBean that = (AdviceBean) o;
+
+        if (idReferences == null && that.idReferences != null) {
+            return false;
+        } else if (idReferences != null && !idReferences.equals(that.idReferences)) {
+            return false;
+        }
+
+        if (uriReferences == null && that.uriReferences != null) {
+            return false;
+        } else if (uriReferences != null && !uriReferences.equals(that.uriReferences)) {
+            return false;
+        }
+
+        if (assertions == null && that.assertions != null) {
+            return false;
+        } else if (assertions != null && !assertions.equals(that.assertions)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (idReferences != null) {
+            result = 31 * result + idReferences.hashCode();
+        }
+        if (uriReferences != null) {
+            result = 31 * result + uriReferences.hashCode();
+        }
+        if (assertions != null) {
+            result = 31 * result + assertions.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeBean.java
new file mode 100644
index 000000000..3b1aa4c49
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeBean.java
@@ -0,0 +1,188 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Class SamlAttribute represents an instance of a SAML attribute.
+ */
+public class AttributeBean {
+    private String simpleName;
+    private String qualifiedName;
+    private String nameFormat;
+    private List<Object> attributeValues;
+
+    /**
+     * Constructor SamlAttribute creates a new SamlAttribute instance.
+     */
+    public AttributeBean() {
+        attributeValues = new ArrayList<>();
+    }
+
+    /**
+     * Constructor SamlAttribute creates a new SamlAttribute instance.
+     *
+     * @param simpleName of type String
+     * @param qualifiedName of type String
+     * @param attributeValues of type List<Object>
+     */
+    public AttributeBean(String simpleName, String qualifiedName, List<Object> attributeValues) {
+        this.simpleName = simpleName;
+        this.qualifiedName = qualifiedName;
+        this.attributeValues = attributeValues;
+    }
+
+    /**
+     * Method getSimpleName returns the simpleName of this SamlAttribute object.
+     *
+     * @return the simpleName (type String) of this SamlAttribute object.
+     */
+    public String getSimpleName() {
+        return simpleName;
+    }
+
+    /**
+     * Method setSimpleName sets the simpleName of this SamlAttribute object.
+     *
+     * @param simpleName the simpleName of this SamlAttribute object.
+     */
+    public void setSimpleName(String simpleName) {
+        this.simpleName = simpleName;
+    }
+
+    /**
+     * Method getNameFormat returns the nameFormat of this SamlAttribute object
+     *
+     * @return the nameFormat of this SamlAttribute object
+     */
+    public String getNameFormat() {
+        return nameFormat;
+    }
+
+    /**
+     * Method setNameFormat sets the nameFormat of this SamlAttribute object.
+     *
+     * @param nameFormat the nameFormat of this SamlAttribute object.
+     */
+    public void setNameFormat(String nameFormat) {
+        this.nameFormat = nameFormat;
+    }
+
+    /**
+     * Method getQualifiedName returns the qualifiedName of this SamlAttribute object.
+     *
+     * @return the qualifiedName (type String) of this SamlAttribute object.
+     */
+    public String getQualifiedName() {
+        return qualifiedName;
+    }
+
+    /**
+     * Method setQualifiedName sets the qualifiedName of this SamlAttribute object.
+     *
+     * @param qualifiedName the qualifiedName of this SamlAttribute object.
+     */
+    public void setQualifiedName(String qualifiedName) {
+        this.qualifiedName = qualifiedName;
+    }
+
+    /**
+     * Method getAttributeValues returns the attributeValues of this SamlAttribute object.
+     *
+     * @return the attributeValues (type List) of this SamlAttribute object.
+     */
+    public List<Object> getAttributeValues() {
+        return attributeValues;
+    }
+
+    /**
+     * Method setAttributeValues sets the attributeValues of this SamlAttribute object.
+     *
+     * @param attributeValues the attributeValues of this SamlAttribute object.
+     */
+    public void setAttributeValues(List<Object> attributeValues) {
+        this.attributeValues = attributeValues;
+    }
+
+    public void addAttributeValue(Object attributeValue) {
+        if (attributeValues == null) {
+            attributeValues = new ArrayList<>();
+        }
+        attributeValues.add(attributeValue);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AttributeBean)) {
+            return false;
+        }
+
+        AttributeBean that = (AttributeBean) o;
+
+        if (attributeValues == null && that.attributeValues != null) {
+            return false;
+        } else if (attributeValues != null && !attributeValues.equals(that.attributeValues)) {
+            return false;
+        }
+
+        if (qualifiedName == null && that.qualifiedName != null) {
+            return false;
+        } else if (qualifiedName != null && !qualifiedName.equals(that.qualifiedName)) {
+            return false;
+        }
+
+        if (nameFormat == null && that.nameFormat != null) {
+            return false;
+        } else if (nameFormat != null && !nameFormat.equals(that.nameFormat)) {
+            return false;
+        }
+
+        if (simpleName == null && that.simpleName != null) {
+            return false;
+        } else if (simpleName != null && !simpleName.equals(that.simpleName)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (simpleName != null) {
+            result = 31 * result + simpleName.hashCode();
+        }
+        if (qualifiedName != null) {
+            result = 31 * result + qualifiedName.hashCode();
+        }
+        if (nameFormat != null) {
+            result = 31 * result + nameFormat.hashCode();
+        }
+        if (attributeValues != null) {
+            result = 31 * result + attributeValues.hashCode();
+        }
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeStatementBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeStatementBean.java
new file mode 100644
index 000000000..486840c11
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AttributeStatementBean.java
@@ -0,0 +1,120 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.List;
+import java.util.ArrayList;
+
+
+/**
+ * Class SamlAttributeStatement represents a SAML attribute statement
+ */
+public class AttributeStatementBean {
+    private SubjectBean subject;
+    private List<AttributeBean> attributeBeans;
+
+    /**
+     * Constructor SamlAttributeStatement creates a new SamlAttributeStatement instance.
+     */
+    public AttributeStatementBean() {
+        attributeBeans = new ArrayList<>();
+    }
+
+    /**
+     * Constructor SamlAttributeStatement creates a new SamlAttributeStatement instance.
+     * @param subject A new SubjectBean instance
+     * @param attributeBeans A list of Attributes
+     */
+    public AttributeStatementBean(
+        SubjectBean subject,
+        List<AttributeBean> attributeBeans
+    ) {
+        this.subject = subject;
+        this.attributeBeans = attributeBeans;
+    }
+
+    /**
+     * Method getSamlAttributes returns the samlAttributes of this SamlAttributeStatement object.
+     *
+     * @return the samlAttributes (type List<SamlAttribute>) of this SamlAttributeStatement object.
+     */
+    public List<AttributeBean> getSamlAttributes() {
+        return attributeBeans;
+    }
+
+    /**
+     * Method setSamlAttributes sets the samlAttributes of this SamlAttributeStatement object.
+     *
+     * @param attributeBeans the samlAttributes of this SamlAttributeStatement object.
+     *
+     */
+    public void setSamlAttributes(List<AttributeBean> attributeBeans) {
+        this.attributeBeans = attributeBeans;
+    }
+
+    /**
+     * Get the Subject
+     * @return the Subject
+     */
+    public SubjectBean getSubject() {
+        return subject;
+    }
+
+    /**
+     * Set the Subject
+     * @param subject the SubjectBean instance to set
+     */
+    public void setSubject(SubjectBean subject) {
+        this.subject = subject;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AttributeStatementBean)) {
+            return false;
+        }
+
+        AttributeStatementBean that = (AttributeStatementBean) o;
+
+        if (attributeBeans == null && that.attributeBeans != null) {
+            return false;
+        } else if (attributeBeans != null && !attributeBeans.equals(that.attributeBeans)) {
+            return false;
+        }
+
+        if (subject == null && that.subject != null) {
+            return false;
+        } else if (subject != null && !subject.equals(that.subject)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = subject != null ? subject.hashCode() : 0;
+        result = 31 * result + (attributeBeans != null ? attributeBeans.hashCode() : 0);
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AudienceRestrictionBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AudienceRestrictionBean.java
new file mode 100644
index 000000000..0bf0e1ede
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AudienceRestrictionBean.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class AudienceRestrictionBean represents a SAML AudienceRestriction object
+ */
+public class AudienceRestrictionBean {
+    private final List<String> audienceURIs = new ArrayList<>();
+
+    /**
+     * Constructor AudienceRestrictionBean creates a new AudienceRestrictionBean instance.
+     */
+    public AudienceRestrictionBean() {
+    }
+
+    /**
+     * Constructor AudienceRestrictionBean creates a new AudienceRestrictionBean instance.
+     *
+     * @param audienceURIs The audienceURI instances
+     */
+    public AudienceRestrictionBean(
+        List<String> audienceURIs
+    ) {
+        if (audienceURIs != null) {
+            this.audienceURIs.addAll(audienceURIs);
+        }
+    }
+
+    /**
+     * Get the audienceURI instances
+     *
+     * @return the audienceURI instances
+     */
+    public List<String> getAudienceURIs() {
+        return audienceURIs;
+    }
+
+    /**
+     * Set the audienceURI instance
+     *
+     * @param audienceURIs the audienceURI instances to set
+     */
+    public void setAudienceURIs(List<String> audienceURIs) {
+        this.audienceURIs.clear();
+        this.audienceURIs.addAll(audienceURIs);
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AudienceRestrictionBean)) {
+            return false;
+        }
+
+        AudienceRestrictionBean that = (AudienceRestrictionBean) o;
+
+        return audienceURIs.equals(that.audienceURIs);
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = 17;
+        result = 31 * result + audienceURIs.hashCode();
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthDecisionStatementBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthDecisionStatementBean.java
new file mode 100644
index 000000000..62326d2a3
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthDecisionStatementBean.java
@@ -0,0 +1,233 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.List;
+import java.util.ArrayList;
+
+
+/**
+ * Class SamlDecision represents the raw data to be used by the <code>SamlAssertionWrapper</code> when
+ * creating SAML Authorization Decision Statements.
+ */
+public class AuthDecisionStatementBean {
+
+    /**
+     * The SAML subject
+     */
+    private SubjectBean subject;
+
+    /**
+     * enum representing the possible decision types as specified in the SAML spec
+     */
+    public enum Decision { PERMIT, INDETERMINATE, DENY }
+
+    /**
+     * The decision rendered by the SAML authority with respect to the specified resource
+     */
+    private Decision decision;
+
+    /**
+     * A URI reference identifying the resource to which access authorization is sought
+     */
+    private String resource;
+
+    /**
+     * The set of actions authorized to be performed on the specified resource (one or more)
+     */
+    private List<ActionBean> actionBeans;
+
+    /**
+     * A set of assertions that the SAML authority relied on in making the decision (optional)
+     */
+    private Object evidence;
+
+    /**
+     * Constructor SamlDecision creates a new SamlDecision instance.
+     */
+    public AuthDecisionStatementBean() {
+        actionBeans = new ArrayList<>();
+    }
+
+    /**
+     * Constructor SamlDecision creates a new SamlDecision instance.
+     *
+     * @param decision of type Decision
+     * @param resource of type String
+     * @param subject of type SubjectBean
+     * @param evidence of type Object
+     * @param actionBeans of type List<SamlAction>
+     */
+    public AuthDecisionStatementBean(
+        Decision decision,
+        String resource,
+        SubjectBean subject,
+        Object evidence,
+        List<ActionBean> actionBeans
+    ) {
+        this.decision = decision;
+        this.resource = resource;
+        this.subject = subject;
+        this.evidence = evidence;
+        this.actionBeans = actionBeans;
+    }
+
+    /**
+     * Method getResource returns the resource of this SamlDecision object.
+     *
+     * @return the resource (type String) of this SamlDecision object.
+     */
+    public String getResource() {
+        return resource;
+    }
+
+    /**
+     * Method setResource sets the resource of this SamlDecision object.
+     *
+     * @param resource the resource of this SamlDecision object.
+     */
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    /**
+     * Method getActions returns the actions of this SamlDecision object.
+     *
+     * @return the actions (type List<SamlAction>) of this SamlDecision object.
+     */
+    public List<ActionBean> getActions() {
+        return actionBeans;
+    }
+
+    /**
+     * Method setActions sets the actions of this SamlDecision object.
+     *
+     * @param actionBeans the actions of this SamlDecision object.
+     */
+    public void setActions(List<ActionBean> actionBeans) {
+        this.actionBeans = actionBeans;
+    }
+
+    /**
+     * Method getDecision returns the decision of this SamlDecision object.
+     *
+     * @return the decision (type Decision) of this SamlDecision object.
+     */
+    public Decision getDecision() {
+        return decision;
+    }
+
+    /**
+     * Method setDecision sets the decision of this SamlDecision object.
+     *
+     * @param decision the decision of this SamlDecision object.
+     */
+    public void setDecision(Decision decision) {
+        this.decision = decision;
+    }
+
+    /**
+     * Method getEvidence returns the evidence of this SamlDecision object.
+     *
+     * @return the evidence (type Object) of this SamlDecision object.
+     */
+    public Object getEvidence() {
+        return evidence;
+    }
+
+    /**
+     * Method setEvidence sets the evidence of this SamlDecision object.
+     *
+     * @param evidence the evidence of this SamlDecision object.
+     */
+    public void setEvidence(Object evidence) {
+        this.evidence = evidence;
+    }
+
+    /**
+     * Get the Subject
+     * @return the Subject
+     */
+    public SubjectBean getSubject() {
+        return subject;
+    }
+
+    /**
+     * Set the Subject
+     * @param subject the SubjectBean instance to set
+     */
+    public void setSubject(SubjectBean subject) {
+        this.subject = subject;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AuthDecisionStatementBean)) {
+            return false;
+        }
+
+        AuthDecisionStatementBean that = (AuthDecisionStatementBean) o;
+
+        if (subject == null && that.subject != null) {
+            return false;
+        } else if (subject != null && !subject.equals(that.subject)) {
+            return false;
+        }
+
+        if (decision == null && that.decision != null) {
+            return false;
+        } else if (decision != null && !decision.equals(that.decision)) {
+            return false;
+        }
+
+        if (evidence == null && that.evidence != null) {
+            return false;
+        } else if (evidence != null && !evidence.equals(that.evidence)) {
+            return false;
+        }
+
+        if (actionBeans == null && that.actionBeans != null) {
+            return false;
+        } else if (actionBeans != null && !actionBeans.equals(that.actionBeans)) {
+            return false;
+        }
+
+        if (resource == null && that.resource != null) {
+            return false;
+        } else if (resource != null && !resource.equals(that.resource)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = subject != null ? subject.hashCode() : 0;
+        result = 31 * result + (decision != null ? decision.hashCode() : 0);
+        result = 31 * result + (evidence != null ? evidence.hashCode() : 0);
+        result = 31 * result + (actionBeans != null ? actionBeans.hashCode() : 0);
+        result = 31 * result + (resource != null ? resource.hashCode() : 0);
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthenticationStatementBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthenticationStatementBean.java
new file mode 100644
index 000000000..dfff5458e
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/AuthenticationStatementBean.java
@@ -0,0 +1,226 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.time.Instant;
+
+/**
+ * Class AuthenticationStatementBean represents the raw data required to create
+ * a SAML v1.1 or v2.0 authentication statement.
+ */
+public class AuthenticationStatementBean {
+    private SubjectBean subject;
+    private Instant sessionNotOnOrAfter;
+    private Instant authenticationInstant;
+    private String authenticationMethod;
+    private SubjectLocalityBean subjectLocality;
+    private String sessionIndex;
+
+    /**
+     * Default constructor
+     */
+    public AuthenticationStatementBean() {
+    }
+
+    /**
+     * Construct a new AuthenticationStatementBean
+     *
+     * @param subject the Subject to set
+     * @param authenticationMethod the Authentication Method to set
+     * @param authenticationInstant the Authentication Instant to set
+     * @param sessionNotOnOrAfter the Session NotOnOrAfter time to set
+     */
+    public AuthenticationStatementBean(
+        SubjectBean subject,
+        String authenticationMethod,
+        Instant authenticationInstant,
+        Instant sessionNotOnOrAfter
+    ) {
+        this.subject = subject;
+        this.authenticationMethod = authenticationMethod;
+        this.authenticationInstant = authenticationInstant;
+        this.sessionNotOnOrAfter = sessionNotOnOrAfter;
+    }
+
+    /**
+     * Get the Subject
+     * @return the subject
+     */
+    public SubjectBean getSubject() {
+        return subject;
+    }
+
+    /**
+     * Set the subject
+     * @param subject the SubjectBean instance to set
+     */
+    public void setSubject(SubjectBean subject) {
+        this.subject = subject;
+    }
+
+    /**
+     * Get the authentication method
+     * @return the authentication method
+     */
+    public String getAuthenticationMethod() {
+        return authenticationMethod;
+    }
+
+    /**
+     * Set the authentication method
+     * @param authenticationMethod the authentication method
+     */
+    public void setAuthenticationMethod(String authenticationMethod) {
+        this.authenticationMethod = authenticationMethod;
+    }
+
+    /**
+     * Get the authentication instant
+     * @return the authentication instant
+     */
+    public Instant getAuthenticationInstant() {
+        return authenticationInstant;
+    }
+
+    /**
+     * Set the authentication instant
+     * @param authenticationInstant the authentication instant
+     */
+    public void setAuthenticationInstant(Instant authenticationInstant) {
+        this.authenticationInstant = authenticationInstant;
+    }
+
+    /**
+     * Get the sessionNotOnOrAfter
+     * @return the sessionNotOnOrAfter
+     */
+    public Instant getSessionNotOnOrAfter() {
+        return sessionNotOnOrAfter;
+    }
+
+    /**
+     * Set the sessionNotOnOrAfter
+     * @param sessionNotOnOrAfter the sessionNotOnOrAfter
+     */
+    public void setSessionNotOnOrAfter(Instant sessionNotOnOrAfter) {
+        this.sessionNotOnOrAfter = sessionNotOnOrAfter;
+    }
+
+    /**
+     * Get Subject Locality.
+     *
+     * @return the subjectLocality
+     */
+    public final SubjectLocalityBean getSubjectLocality() {
+        return subjectLocality;
+    }
+
+    /**
+     * Set Subject Locality.
+     *
+     * @param subjectLocality the subjectLocality to set
+     */
+    public final void setSubjectLocality(final SubjectLocalityBean subjectLocality) {
+        this.subjectLocality = subjectLocality;
+    }
+
+    /**
+     * Get the session index.
+     *
+     * @return the sessionIndex
+     */
+    public final String getSessionIndex() {
+        return sessionIndex;
+    }
+
+    /**
+     * Set the session index.
+     *
+     * @param sessionIndex the sessionIndex to set
+     */
+    public final void setSessionIndex(final String sessionIndex) {
+        this.sessionIndex = sessionIndex;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof AuthenticationStatementBean)) {
+            return false;
+        }
+
+        AuthenticationStatementBean that = (AuthenticationStatementBean) o;
+
+        if (authenticationInstant == null && that.authenticationInstant != null) {
+            return false;
+        } else if (authenticationInstant != null
+            && !authenticationInstant.equals(that.authenticationInstant)) {
+            return false;
+        }
+
+        if (sessionNotOnOrAfter == null && that.sessionNotOnOrAfter != null) {
+            return false;
+        } else if (sessionNotOnOrAfter != null
+            && !sessionNotOnOrAfter.equals(that.sessionNotOnOrAfter)) {
+            return false;
+        }
+
+        if (authenticationMethod == null && that.authenticationMethod != null) {
+            return false;
+        } else if (authenticationMethod != null
+            && !authenticationMethod.equals(that.authenticationMethod)) {
+            return false;
+        }
+
+        if (subject == null && that.subject != null) {
+            return false;
+        } else if (subject != null
+            && !subject.equals(that.subject)) {
+            return false;
+        }
+
+        if (subjectLocality == null && that.subjectLocality != null) {
+            return false;
+        } else if (subjectLocality != null && !subjectLocality.equals(that.subjectLocality)) {
+            return false;
+        }
+
+        if (sessionIndex == null && that.sessionIndex != null) {
+            return false;
+        } else if (sessionIndex != null && !sessionIndex.equals(that.sessionIndex)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = subject != null ? subject.hashCode() : 0;
+        result = 31 * result + (authenticationInstant != null ? authenticationInstant.hashCode() : 0);
+        result = 31 * result + (sessionNotOnOrAfter != null ? sessionNotOnOrAfter.hashCode() : 0);
+        result = 31 * result + (authenticationMethod != null ? authenticationMethod.hashCode() : 0);
+        result = 31 * result + (subjectLocality != null ? subjectLocality.hashCode() : 0);
+        result = 31 * result + (sessionIndex != null ? sessionIndex.hashCode() : 0);
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ConditionsBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ConditionsBean.java
new file mode 100644
index 000000000..139ed2fcf
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ConditionsBean.java
@@ -0,0 +1,289 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.time.Instant;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Class ConditionsBean represents a SAML Conditions object (can be used to create
+ * both SAML v1.1 and v2.0 statements)
+ */
+public class ConditionsBean {
+    private Instant notBefore;
+    private Instant notAfter;
+    private long tokenPeriodSeconds;
+    private List<AudienceRestrictionBean> audienceRestrictions;
+    private boolean oneTimeUse;
+    private ProxyRestrictionBean proxyRestriction;
+    private List<DelegateBean> delegates;
+
+    /**
+     * Constructor ConditionsBean creates a new ConditionsBean instance.
+     */
+    public ConditionsBean() {
+    }
+
+    /**
+     * Constructor ConditionsBean creates a new ConditionsBean instance.
+     *
+     * @param notBefore The notBefore instance
+     * @param notAfter The notAfter instance
+     */
+    public ConditionsBean(
+        Instant notBefore,
+        Instant notAfter
+    ) {
+        if (notBefore != null) {
+            this.notBefore = Date.from(notBefore).toInstant();
+        }
+        if (notAfter != null) {
+            this.notAfter = Date.from(notAfter).toInstant();
+        }
+    }
+
+    /**
+     * Constructor ConditionsBean creates a new ConditionsBean instance.
+     *
+     * @param tokenPeriodMinutes how long the token is valid for in minutes
+     */
+    public ConditionsBean(
+        int tokenPeriodMinutes
+    ) {
+        this.tokenPeriodSeconds = tokenPeriodMinutes * 60L;
+    }
+
+    /**
+     * Get the notBefore instance
+     *
+     * @return the notBefore instance
+     */
+    public Instant getNotBefore() {
+        return notBefore;
+    }
+
+    /**
+     * Set the notBefore instance
+     *
+     * @param notBefore the notBefore instance to set
+     */
+    public void setNotBefore(Instant notBefore) {
+        if (notBefore != null) {
+            this.notBefore = Date.from(notBefore).toInstant();
+        } else {
+            this.notBefore = null;
+        }
+    }
+
+    /**
+     * Get the notAfter instance
+     *
+     * @return the notAfter instance
+     */
+    public Instant getNotAfter() {
+        return notAfter;
+    }
+
+    /**
+     * Set the notAfter instance
+     *
+     * @param notAfter the notAfter instance to set
+     */
+    public void setNotAfter(Instant notAfter) {
+        if (notAfter != null) {
+            this.notAfter = Date.from(notAfter).toInstant();
+        } else {
+            this.notAfter = null;
+        }
+    }
+
+    /**
+     * Get the tokenPeriodMinutes of this object.
+     *
+     * @return the tokenPeriodMinutes (type int)
+     */
+    public int getTokenPeriodMinutes() {
+        return (int)(tokenPeriodSeconds / 60L);
+    }
+
+    /**
+     * Set the tokenPeriodMinutes.
+     *
+     * @param tokenPeriodMinutes the tokenPeriodMinutes to set
+     */
+    public void setTokenPeriodMinutes(int tokenPeriodMinutes) {
+        this.tokenPeriodSeconds = tokenPeriodMinutes * 60L;
+    }
+
+    /**
+     * Get the tokenPeriodSeconds of this object.
+     *
+     * @return the tokenPeriodSeconds (type long)
+     */
+    public long getTokenPeriodSeconds() {
+        return tokenPeriodSeconds;
+    }
+
+    /**
+     * Set the tokenPeriodSeconds.
+     *
+     * @param tokenPeriodSeconds the tokenPeriodSeconds to set
+     */
+    public void setTokenPeriodSeconds(long tokenPeriodSeconds) {
+        this.tokenPeriodSeconds = tokenPeriodSeconds;
+    }
+
+    /**
+     * Get the audienceRestrictions instances
+     *
+     * @return the audienceRestrictions instances
+     */
+    public List<AudienceRestrictionBean> getAudienceRestrictions() {
+        return audienceRestrictions;
+    }
+
+    /**
+     * Set the audienceRestrictions instance
+     *
+     * @param audienceRestrictions the audienceRestrictions instance to set
+     */
+    public void setAudienceRestrictions(List<AudienceRestrictionBean> audienceRestrictions) {
+        this.audienceRestrictions = audienceRestrictions;
+    }
+
+    /**
+     * Get whether to include a OneTimeUse Element or not. Only applies to SAML2.
+     * @return whether to include a OneTimeUse Element or not.
+     */
+    public boolean isOneTimeUse() {
+        return oneTimeUse;
+    }
+
+    /**
+     * Set whether to include a OneTimeUse Element or not. Only applies to SAML2.
+     * @param oneTimeUse whether to include a OneTimeUse Element or not.
+     */
+    public void setOneTimeUse(boolean oneTimeUse) {
+        this.oneTimeUse = oneTimeUse;
+    }
+
+    public ProxyRestrictionBean getProxyRestriction() {
+        return proxyRestriction;
+    }
+
+    public void setProxyRestriction(ProxyRestrictionBean proxyRestriction) {
+        this.proxyRestriction = proxyRestriction;
+    }
+
+    public List<DelegateBean> getDelegates() {
+        return delegates;
+    }
+
+    public void setDelegates(List<DelegateBean> delegates) {
+        this.delegates = delegates;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof ConditionsBean)) {
+            return false;
+        }
+
+        ConditionsBean that = (ConditionsBean) o;
+
+        if (tokenPeriodSeconds != that.tokenPeriodSeconds) {
+            return false;
+        }
+
+        if (notBefore == null && that.notBefore != null) {
+            return false;
+        } else if (notBefore != null && !notBefore.equals(that.notBefore)) {
+            return false;
+        }
+
+        if (notAfter == null && that.notAfter != null) {
+            return false;
+        } else if (notAfter != null && !notAfter.equals(that.notAfter)) {
+            return false;
+        }
+
+        if (audienceRestrictions == null && that.audienceRestrictions != null) {
+            return false;
+        } else if (audienceRestrictions != null
+                && !audienceRestrictions.equals(that.audienceRestrictions)) {
+            return false;
+        }
+
+        if (oneTimeUse != that.oneTimeUse) {
+            return false;
+        }
+
+        if (proxyRestriction == null && that.proxyRestriction != null) {
+            return false;
+        } else if (proxyRestriction != null
+            && !proxyRestriction.equals(that.proxyRestriction)) {
+            return false;
+        }
+
+        if (delegates == null && that.delegates != null) {
+            return false;
+        } else if (delegates != null && !delegates.equals(that.delegates)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = (int)tokenPeriodSeconds;
+        if (notBefore != null) {
+            result = 31 * result + notBefore.hashCode();
+        }
+        if (notAfter != null) {
+            result = 31 * result + notAfter.hashCode();
+        }
+        if (audienceRestrictions != null) {
+            result = 31 * result + audienceRestrictions.hashCode();
+        }
+        result = 31 * result + (oneTimeUse ? 1 : 0);
+        if (proxyRestriction != null) {
+            result = 31 * result + proxyRestriction.hashCode();
+        }
+        if (delegates != null) {
+            result = 31 * result + delegates.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/DelegateBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/DelegateBean.java
new file mode 100644
index 000000000..c324ef1db
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/DelegateBean.java
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.time.Instant;
+import java.util.Date;
+
+/**
+ * Class DelegateBean represents a SAML 2.0 Delegate object. Only NameIDs are supported for now, not
+ * BaseID or EncryptedIDs.
+ *
+ * See:
+ * http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-delegation-cs-01.pdf
+ */
+public class DelegateBean {
+    private Instant delegationInstant;
+    private String confirmationMethod;
+    private NameIDBean nameIDBean;
+
+    public Instant getDelegationInstant() {
+        return delegationInstant;
+    }
+
+    public void setDelegationInstant(Instant delegationInstant) {
+        if (delegationInstant != null) {
+            this.delegationInstant = Date.from(delegationInstant).toInstant();
+        } else {
+            this.delegationInstant = null;
+        }
+    }
+
+    public String getConfirmationMethod() {
+        return confirmationMethod;
+    }
+
+    public void setConfirmationMethod(String confirmationMethod) {
+        this.confirmationMethod = confirmationMethod;
+    }
+
+    public NameIDBean getNameIDBean() {
+        return nameIDBean;
+    }
+
+    public void setNameIDBean(NameIDBean nameIDBean) {
+        this.nameIDBean = nameIDBean;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof DelegateBean)) {
+            return false;
+        }
+
+        DelegateBean that = (DelegateBean) o;
+
+        if (delegationInstant == null && that.delegationInstant != null) {
+            return false;
+        } else if (delegationInstant != null && !delegationInstant.equals(that.delegationInstant)) {
+            return false;
+        }
+
+        if (confirmationMethod == null && that.confirmationMethod != null) {
+            return false;
+        } else if (confirmationMethod != null && !confirmationMethod.equals(that.confirmationMethod)) {
+            return false;
+        }
+
+        if (nameIDBean == null && that.nameIDBean != null) {
+            return false;
+        } else if (nameIDBean != null && !nameIDBean.equals(that.nameIDBean)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (delegationInstant != null) {
+            result = 31 * result + delegationInstant.hashCode();
+        }
+        if (confirmationMethod != null) {
+            result = 31 * result + confirmationMethod.hashCode();
+        }
+        if (nameIDBean != null) {
+            result = 31 * result + nameIDBean.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/KeyInfoBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/KeyInfoBean.java
new file mode 100644
index 000000000..3d6ef6bce
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/KeyInfoBean.java
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.security.PublicKey;
+import java.security.cert.X509Certificate;
+
+import org.w3c.dom.Element;
+
+
+/**
+ * Class KeyInfoBean represents a KeyInfo structure that will be embedded in a SAML Subject.
+ */
+public class KeyInfoBean {
+
+    public enum CERT_IDENTIFIER {
+        X509_CERT, X509_ISSUER_SERIAL, KEY_VALUE
+    }
+
+    private X509Certificate cert;
+    private CERT_IDENTIFIER certIdentifier = CERT_IDENTIFIER.X509_CERT;
+    private PublicKey publicKey;
+    private byte[] ephemeralKey;
+    private Element keyInfoElement;
+
+    /**
+     * Constructor KeyInfoBean creates a new KeyInfoBean instance.
+     */
+    public KeyInfoBean() {
+    }
+
+    /**
+     * Method getCertificate returns the certificate of this KeyInfoBean object.
+     *
+     * @return the cert (type X509Certificate) of this KeyInfoBean object.
+     */
+    public X509Certificate getCertificate() {
+        return cert;
+    }
+
+    /**
+     * Method setCertificate sets the cert of this KeyInfoBean object.
+     *
+     * @param cert the cert of this KeyInfoBean object.
+     */
+    public void setCertificate(X509Certificate cert) {
+        this.cert = cert;
+    }
+
+    /**
+     * Method getPublicKey returns the public key of this KeyInfoBean object.
+     *
+     * @return the publicKey (type PublicKey) of this KeyInfoBean object.
+     */
+    public PublicKey getPublicKey() {
+        return publicKey;
+    }
+
+    /**
+     * Method setPublicKey sets the publicKey of this KeyInfoBean object.
+     *
+     * @param publicKey the publicKey of this KeyInfoBean object.
+     */
+    public void setPublicKey(PublicKey publicKey) {
+        this.publicKey = publicKey;
+    }
+
+    /**
+     * Method getCertIdentifer returns the cert identifer of this KeyInfoBean object.
+     *
+     * @return the certIdentifier (type CERT_IDENTIFIER) of this KeyInfoBean object.
+     */
+    public CERT_IDENTIFIER getCertIdentifer() {
+        return certIdentifier;
+    }
+
+    /**
+     * Method setCertIdentifer sets the cert identifier of this KeyInfoBean object.
+     *
+     * @param certIdentifier the certIdentifier of this KeyInfoBean object.
+     */
+    public void setCertIdentifer(CERT_IDENTIFIER certIdentifier) {
+        this.certIdentifier = certIdentifier;
+    }
+
+    public byte[] getEphemeralKey() {
+        return ephemeralKey;
+    }
+
+    public void setEphemeralKey(byte[] ephemeralKey) {
+        this.ephemeralKey = ephemeralKey;
+    }
+
+    /**
+     * Method getElement returns the DOM Element of this KeyInfoBean object.
+     *
+     * @return the keyInfoElement (type Element) of this KeyInfoBean object.
+     */
+    public Element getElement() {
+        return keyInfoElement;
+    }
+
+    /**
+     * Method setElement sets the DOM Element of this KeyInfoBean object.
+     *
+     * @param keyInfoElement the DOM Element of this KeyInfoBean object.
+     */
+    public void setElement(Element keyInfoElement) {
+        this.keyInfoElement = keyInfoElement;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof KeyInfoBean)) {
+            return false;
+        }
+
+        KeyInfoBean that = (KeyInfoBean) o;
+
+        if (certIdentifier != that.certIdentifier) {
+            return false;
+        }
+        if (cert == null && that.cert != null) {
+            return false;
+        } else if (cert != null && !cert.equals(that.cert)) {
+            return false;
+        }
+
+        if (publicKey == null && that.publicKey != null) {
+            return false;
+        } else if (publicKey != null && !publicKey.equals(that.publicKey)) {
+            return false;
+        }
+
+        if (keyInfoElement == null && that.keyInfoElement != null) {
+            return false;
+        } else if (keyInfoElement != null && !keyInfoElement.equals(that.keyInfoElement)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashCode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = certIdentifier.hashCode();
+        if (cert != null) {
+            result = 31 * result + cert.hashCode();
+        }
+        if (publicKey != null) {
+            result = 31 * result + publicKey.hashCode();
+        }
+        if (keyInfoElement != null) {
+            result = 31 * result + keyInfoElement.hashCode();
+        }
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/NameIDBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/NameIDBean.java
new file mode 100644
index 000000000..db91e3294
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/NameIDBean.java
@@ -0,0 +1,168 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+/**
+ * Class NameIDBean represents a SAML NameID (can be used to create both SAML v1.1 and v2.0 statements)
+ */
+public class NameIDBean {
+    private String nameValue;
+    private String nameIDFormat = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";
+    private String nameQualifier;
+    private String spNameQualifier;
+    private String spProvidedID;
+
+    /**
+     * Constructor NameIDBean creates a new NameIDBean instance.
+     */
+    public NameIDBean() {
+    }
+
+    /**
+     * Constructor NameIDBean creates a new NameIDBean instance.
+     *
+     * @param nameValue of type String
+     * @param nameQualifier of type String
+     */
+    public NameIDBean(
+        String nameValue,
+        String nameQualifier,
+        String nameIDFormat
+    ) {
+        this.setNameValue(nameValue);
+        this.setNameQualifier(nameQualifier);
+        this.setNameIDFormat(nameIDFormat);
+    }
+
+    public String getNameValue() {
+        return nameValue;
+    }
+
+    public void setNameValue(String nameValue) {
+        this.nameValue = nameValue;
+    }
+
+    public String getNameIDFormat() {
+        return nameIDFormat;
+    }
+
+    public void setNameIDFormat(String nameIDFormat) {
+        this.nameIDFormat = nameIDFormat;
+    }
+
+    public String getNameQualifier() {
+        return nameQualifier;
+    }
+
+    public void setNameQualifier(String nameQualifier) {
+        this.nameQualifier = nameQualifier;
+    }
+
+    public String getSPNameQualifier() {
+        return spNameQualifier;
+    }
+
+    public void setSPNameQualifier(String spNameQualifier) {
+        this.spNameQualifier = spNameQualifier;
+    }
+
+    public String getSPProvidedID() {
+        return spProvidedID;
+    }
+
+    public void setSPProvidedID(String spProvidedID) {
+        this.spProvidedID = spProvidedID;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof NameIDBean)) {
+            return false;
+        }
+
+        NameIDBean that = (NameIDBean) o;
+
+        if (nameValue == null && that.nameValue != null) {
+            return false;
+        } else if (nameValue != null && !nameValue.equals(that.nameValue)) {
+            return false;
+        }
+
+        if (nameIDFormat == null && that.nameIDFormat != null) {
+            return false;
+        } else if (nameIDFormat != null && !nameIDFormat.equals(that.nameIDFormat)) {
+            return false;
+        }
+
+        if (nameQualifier == null && that.nameQualifier != null) {
+            return false;
+        } else if (nameQualifier != null && !nameQualifier.equals(that.nameQualifier)) {
+            return false;
+        }
+
+        if (spNameQualifier == null && that.spNameQualifier != null) {
+            return false;
+        } else if (spNameQualifier != null && !spNameQualifier.equals(that.spNameQualifier)) {
+            return false;
+        }
+
+        if (spProvidedID == null && that.spProvidedID != null) {
+            return false;
+        } else if (spProvidedID != null && !spProvidedID.equals(that.spProvidedID)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (nameValue != null) {
+            result = nameValue.hashCode();
+        }
+        if (nameIDFormat != null) {
+            result = 31 * result + nameIDFormat.hashCode();
+        }
+        if (nameQualifier != null) {
+            result = 31 * result + nameQualifier.hashCode();
+        }
+        if (spNameQualifier != null) {
+            result = 31 * result + spNameQualifier.hashCode();
+        }
+        if (spProvidedID != null) {
+            result = 31 * result + spProvidedID.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ProxyRestrictionBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ProxyRestrictionBean.java
new file mode 100644
index 000000000..7546817c2
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/ProxyRestrictionBean.java
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Class ProxyRestrictionBean represents a SAML 2.0 ProxyRestrictionBean object
+ */
+public class ProxyRestrictionBean {
+    private int count;
+    private final List<String> audienceURIs = new ArrayList<>();
+
+    /**
+     * Constructor ProxyRestrictionBean creates a new ProxyRestrictionBean instance.
+     */
+    public ProxyRestrictionBean() {
+    }
+
+    /**
+     * Constructor ProxyRestrictionBean creates a new ProxyRestrictionBean instance.
+     *
+     * @param count The count instance
+     * @param audienceURIs The audienceURI instances
+     */
+    public ProxyRestrictionBean(
+        int count,
+        List<String> audienceURIs
+    ) {
+        this.setCount(count);
+        if (audienceURIs != null) {
+            this.audienceURIs.addAll(audienceURIs);
+        }
+    }
+
+    /**
+     * Get the audienceURI instances
+     *
+     * @return the audienceURI instances
+     */
+    public List<String> getAudienceURIs() {
+        return audienceURIs;
+    }
+
+    public int getCount() {
+        return count;
+    }
+
+    public void setCount(int count) {
+        this.count = count;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof ProxyRestrictionBean)) {
+            return false;
+        }
+
+        ProxyRestrictionBean that = (ProxyRestrictionBean) o;
+
+        if (count != that.count) {
+            return false;
+        }
+
+        return audienceURIs.equals(that.audienceURIs);
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = count;
+        result = 31 * result + audienceURIs.hashCode();
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectBean.java
new file mode 100644
index 000000000..067daf87a
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectBean.java
@@ -0,0 +1,311 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+/**
+ * Class SubjectBean represents a SAML subject (can be used to create
+ * both SAML v1.1 and v2.0 statements)
+ */
+public class SubjectBean {
+    private final NameIDBean nameID = new NameIDBean();
+    private String subjectConfirmationMethod;
+    private KeyInfoBean keyInfo;
+    private SubjectConfirmationDataBean subjectConfirmationData;
+    private NameIDBean subjectConfirmationNameID;
+
+    /**
+     * Constructor SubjectBean creates a new SubjectBean instance.
+     */
+    public SubjectBean() {
+    }
+
+    /**
+     * Constructor SubjectBean creates a new SubjectBean instance.
+     *
+     * @param subjectName of type String
+     * @param subjectNameQualifier of type String
+     * @param subjectConfirmationMethod of type String
+     */
+    public SubjectBean(
+        String subjectName,
+        String subjectNameQualifier,
+        String subjectConfirmationMethod
+    ) {
+        nameID.setNameValue(subjectName);
+        nameID.setNameQualifier(subjectNameQualifier);
+        this.subjectConfirmationMethod = subjectConfirmationMethod;
+    }
+
+    /**
+     * Constructor SubjectBean creates a new SubjectBean instance.
+     *
+     * @param subjectName of type String
+     * @param subjectNameQualifier of type String
+     * @param subjectConfirmationMethod of type String
+     * @param subjectNameIDFormat of type String
+     */
+    public SubjectBean(
+        String subjectName,
+        String subjectNameQualifier,
+        String subjectConfirmationMethod,
+        String subjectNameIDFormat
+    ) {
+        this(subjectName, subjectNameQualifier, subjectConfirmationMethod);
+        nameID.setNameIDFormat(subjectNameIDFormat);
+    }
+
+    /**
+     * Constructor SubjectBean creates a new SubjectBean instance.
+     *
+     * @param subjectName of type String
+     * @param subjectNameQualifier of type String
+     * @param subjectConfirmationMethod of type String
+     * @param subjectNameIDFormat of type String
+     * @param subjectNameSPProvidedID of type String
+     */
+    public SubjectBean(
+            String subjectName,
+            String subjectNameQualifier,
+            String subjectConfirmationMethod,
+            String subjectNameIDFormat,
+            String subjectNameSPProvidedID
+    ) {
+        this(subjectName, subjectNameQualifier, subjectConfirmationMethod, subjectNameIDFormat);
+        nameID.setSPProvidedID(subjectNameSPProvidedID);
+    }
+
+    /**
+     * Method getSubjectName returns the subjectName of this SubjectBean object.
+     *
+     * @return the subjectName (type String) of this SubjectBean object.
+     */
+    public String getSubjectName() {
+        return nameID.getNameValue();
+    }
+
+    /**
+     * Method setSubjectName sets the subjectName of this SubjectBean object.
+     *
+     * @param subjectName the subjectName of this SubjectBean object.
+     */
+    public void setSubjectName(String subjectName) {
+        nameID.setNameValue(subjectName);
+    }
+
+    /**
+     * Method getSubjectNameQualifier returns the subjectNameQualifier of this SubjectBean object.
+     *
+     * @return the subjectNameQualifier (type String) of this SubjectBean object.
+     */
+    public String getSubjectNameQualifier() {
+        return nameID.getNameQualifier();
+    }
+
+    /**
+     * Method setSubjectNameQualifier sets the subjectNameQualifier of this SubjectBean object.
+     *
+     * @param subjectNameQualifier the subjectNameQualifier of this SubjectBean object.
+     */
+    public void setSubjectNameQualifier(String subjectNameQualifier) {
+        nameID.setNameQualifier(subjectNameQualifier);
+    }
+
+    /**
+     * Method getSubjectConfirmationMethod returns the subjectConfirmationMethod of
+     * this SubjectBean object.
+     *
+     * @return the subjectConfirmationMethod (type String) of this SubjectBean object.
+     */
+    public String getSubjectConfirmationMethod() {
+        return subjectConfirmationMethod;
+    }
+
+    /**
+     * Method setSubjectConfirmationMethod sets the subjectConfirmationMethod of
+     * this SubjectBean object.
+     *
+     * @param subjectConfirmationMethod the subjectConfirmationMethod of this
+     *        SubjectBean object.
+     */
+    public void setSubjectConfirmationMethod(String subjectConfirmationMethod) {
+        this.subjectConfirmationMethod = subjectConfirmationMethod;
+    }
+
+    /**
+     * Method getSubjectNameIDFormat returns the subjectNameIDFormat of this SubjectBean
+     * object.
+     *
+     * @return the subjectNameIDFormat (type String) of this SubjectBean object.
+     */
+    public String getSubjectNameIDFormat() {
+        return nameID.getNameIDFormat();
+    }
+
+    /**
+     * Method setSubjectNameIDFormat sets the subjectNameIDFormat of this SubjectBean
+     * object.
+     *
+     * @param subjectNameIDFormat the subjectNameIDFormat of this SubjectBean object.
+     */
+    public void setSubjectNameIDFormat(String subjectNameIDFormat) {
+        nameID.setNameIDFormat(subjectNameIDFormat);
+    }
+
+    public String getSubjectNameSPNameQualifier() {
+        return nameID.getSPNameQualifier();
+    }
+
+    public void setSubjectNameSPNameQualifier(String subjectNameSPNameQualifier) {
+        nameID.setSPNameQualifier(subjectNameSPNameQualifier);
+    }
+
+    public String getSubjectNameSPProvidedID() {
+        return nameID.getSPProvidedID();
+    }
+
+    public void setSubjectNameSPProvidedID(String subjectNameSPProvidedID) {
+        nameID.setSPProvidedID(subjectNameSPProvidedID);
+    }
+
+    /**
+     * Method getKeyInfo returns the keyInfo of this SubjectBean object.
+     *
+     * @return the keyInfo (type KeyInfoBean) of this SubjectBean object.
+     */
+    public KeyInfoBean getKeyInfo() {
+        return keyInfo;
+    }
+
+    /**
+     * Method setKeyInfo sets the keyInfo of this SubjectBean object.
+     *
+     * @param keyInfo the keyInfo of this SubjectBean object.
+     */
+    public void setKeyInfo(KeyInfoBean keyInfo) {
+        this.keyInfo = keyInfo;
+    }
+
+    /**
+     * Set the SubjectConfirmationData of this SubjectBean object
+     * @return the SubjectConfirmationData of this SubjectBean object
+     */
+    public SubjectConfirmationDataBean getSubjectConfirmationData() {
+        return subjectConfirmationData;
+    }
+
+    /**
+     * Get the SubjectConfirmationData of this SubjectBean object
+     * @param subjectConfirmationData the SubjectConfirmationData of this SubjectBean object
+     */
+    public void setSubjectConfirmationData(
+        SubjectConfirmationDataBean subjectConfirmationData
+    ) {
+        this.subjectConfirmationData = subjectConfirmationData;
+    }
+
+    /**
+     * Get the NameId of the SubjectConfirmation object
+     * @return the NameId of the SubjectConfirmation object
+     */
+    public NameIDBean getSubjectConfirmationNameID() {
+        return subjectConfirmationNameID;
+    }
+
+    /**
+     * Set the NameID of the SubjectConfirmation object
+     * @param subjectConfirmationNameID the NameID of the SubjectConfirmation object
+     */
+    public void setSubjectConfirmationNameID(NameIDBean subjectConfirmationNameID) {
+        this.subjectConfirmationNameID = subjectConfirmationNameID;
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof SubjectBean)) {
+            return false;
+        }
+
+        SubjectBean that = (SubjectBean) o;
+
+        if (!nameID.equals(that.nameID)) {
+            return false;
+        }
+
+        if (subjectConfirmationMethod == null && that.subjectConfirmationMethod != null) {
+            return false;
+        } else if (subjectConfirmationMethod != null
+            && !subjectConfirmationMethod.equals(that.subjectConfirmationMethod)) {
+            return false;
+        }
+
+        if (keyInfo == null && that.keyInfo != null) {
+            return false;
+        } else if (keyInfo != null && !keyInfo.equals(that.keyInfo)) {
+            return false;
+        }
+
+        if (subjectConfirmationData == null && that.subjectConfirmationData != null) {
+            return false;
+        } else if (subjectConfirmationData != null
+            && !subjectConfirmationData.equals(that.subjectConfirmationData)) {
+            return false;
+        }
+
+        if (subjectConfirmationNameID == null && that.subjectConfirmationNameID != null) {
+            return false;
+        } else if (subjectConfirmationNameID != null
+            && !subjectConfirmationNameID.equals(that.subjectConfirmationNameID)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = nameID.hashCode();
+        if (subjectConfirmationMethod != null) {
+            result = 31 * result + subjectConfirmationMethod.hashCode();
+        }
+        if (keyInfo != null) {
+            result = 31 * result + keyInfo.hashCode();
+        }
+        if (subjectConfirmationData != null) {
+            result = 31 * result + subjectConfirmationData.hashCode();
+        }
+        if (subjectConfirmationNameID != null) {
+            result = 31 * result + subjectConfirmationNameID.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectConfirmationDataBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectConfirmationDataBean.java
new file mode 100644
index 000000000..746a6343c
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectConfirmationDataBean.java
@@ -0,0 +1,248 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Class SubjectConfirmationDataBean represents a SAML (2) SubjectConfirmationData. Please note that
+ * KeyInfo functionality is in SubjectBean for backwards compatibility reasons.
+ */
+public class SubjectConfirmationDataBean {
+    private String recipient;
+    private String address;
+    private String inResponseTo;
+    private Instant notBefore;
+    private Instant notAfter;
+    private List<Object> any;
+
+    /**
+     * Constructor SubjectConfirmationDataBean creates a new SubjectConfirmationDataBean instance.
+     */
+    public SubjectConfirmationDataBean() {
+    }
+
+    /**
+     * Get the recipient of the SubjectConfirmationDataBean
+     * @return the recipient of the SubjectConfirmationDataBean
+     */
+    public String getRecipient() {
+        return recipient;
+    }
+
+    /**
+     * Set the recipient of the SubjectConfirmationDataBean
+     * @param recipient the recipient of the SubjectConfirmationDataBean
+     */
+    public void setRecipient(String recipient) {
+        this.recipient = recipient;
+    }
+
+    /**
+     * Get the address of the SubjectConfirmationDataBean
+     * @return the address of the SubjectConfirmationDataBean
+     */
+    public String getAddress() {
+        return address;
+    }
+
+    /**
+     * Set the address of the SubjectConfirmationDataBean
+     * @param address the address of the SubjectConfirmationDataBean
+     */
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    /**
+     * Get the InResponseTo element of the SubjectConfirmationDataBean
+     * @return the InResponseTo element of the SubjectConfirmationDataBean
+     */
+    public String getInResponseTo() {
+        return inResponseTo;
+    }
+
+    /**
+     * Set the InResponseTo element of the SubjectConfirmationDataBean
+     * @param inResponseTo the InResponseTo element of the SubjectConfirmationDataBean
+     */
+    public void setInResponseTo(String inResponseTo) {
+        this.inResponseTo = inResponseTo;
+    }
+
+    /**
+     * Get the NotBefore time of the SubjectConfirmationDataBean
+     * @return the NotBefore time of the SubjectConfirmationDataBean
+     */
+    public Instant getNotBefore() {
+        return notBefore;
+    }
+
+    /**
+     * Set the notBefore instance
+     *
+     * @param notBefore the notBefore instance to set
+     */
+    public void setNotBefore(Instant notBefore) {
+        if (notBefore != null) {
+            this.notBefore = Date.from(notBefore).toInstant();
+        } else {
+            this.notBefore = null;
+        }
+    }
+
+    /**
+     * Get the NotOnOrAfter time of the SubjectConfirmationDataBean
+     * @return the NotOnOrAfter time of the SubjectConfirmationDataBean
+     */
+    public Instant getNotAfter() {
+        return notAfter;
+    }
+
+    /**
+     * Set the notAfter instance
+     *
+     * @param notAfter the notAfter instance to set
+     */
+    public void setNotAfter(Instant notAfter) {
+        if (notAfter != null) {
+            this.notAfter = Date.from(notAfter).toInstant();
+        } else {
+            this.notAfter = null;
+        }
+    }
+
+    /**
+     * Get the list of additional elements
+     *
+     * @return list of additional elements
+     */
+    public List<Object> getAny() {
+        return any;
+    }
+
+    /**
+     * Set the list of additional elements
+     *
+     * @param any the list of additional elements
+     */
+    public void setAny(List<Object> any) {
+        this.any = any;
+    }
+
+    /**
+     * Adds an additional element
+     *
+     * @param obj additional element
+     */
+    public void addAny(Object obj) {
+        if (any == null) {
+            any = new ArrayList<>();
+        }
+        any.add(obj);
+    }
+
+    /**
+     * Method equals ...
+     *
+     * @param o of type Object
+     * @return boolean
+     */
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof SubjectConfirmationDataBean)) {
+            return false;
+        }
+
+        SubjectConfirmationDataBean that = (SubjectConfirmationDataBean) o;
+
+        if (recipient == null && that.recipient != null) {
+            return false;
+        } else if (recipient != null && !recipient.equals(that.recipient)) {
+            return false;
+        }
+
+        if (address == null && that.address != null) {
+            return false;
+        } else if (address != null && !address.equals(that.address)) {
+            return false;
+        }
+
+        if (inResponseTo == null && that.inResponseTo != null) {
+            return false;
+        } else if (inResponseTo != null && !inResponseTo.equals(that.inResponseTo)) {
+            return false;
+        }
+
+        if (notBefore == null && that.notBefore != null) {
+            return false;
+        } else if (notBefore != null && !notBefore.equals(that.notBefore)) {
+            return false;
+        }
+
+        if (notAfter == null && that.notAfter != null) {
+            return false;
+        } else if (notAfter != null && !notAfter.equals(that.notAfter)) {
+            return false;
+        }
+
+        if (any == null && that.any != null) {
+            return false;
+        } else if (any != null && !any.equals(that.any)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @return the hashcode of this object
+     */
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (recipient != null) {
+            result = recipient.hashCode();
+        }
+        if (address != null) {
+            result = 31 * result + address.hashCode();
+        }
+        if (inResponseTo != null) {
+            result = 31 * result + inResponseTo.hashCode();
+        }
+        if (notBefore != null) {
+            result = 31 * result + notBefore.hashCode();
+        }
+        if (notAfter != null) {
+            result = 31 * result + notAfter.hashCode();
+        }
+        if (any != null) {
+            result = 31 * result + any.hashCode();
+        }
+        return result;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectLocalityBean.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectLocalityBean.java
new file mode 100644
index 000000000..f02e2cfac
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/SubjectLocalityBean.java
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+/**
+ * This class represents a SubjectLocality.
+ */
+public class SubjectLocalityBean {
+
+    /** The ipAddress. */
+    private String ipAddress;
+
+    /** The DNS Address. */
+    private String dnsAddress;
+
+    /**
+     * Default constructor explicitly provided since other constructors would
+     * prevent its automatic creation.
+     */
+    public SubjectLocalityBean() {
+        //
+    }
+
+    /**
+     * Constructor for creating a SubjectLocalityBean with ip and dns addresses.
+     *
+     * @param ipAddress ip address
+     * @param dnsAddress dns address
+     */
+    public SubjectLocalityBean(final String ipAddress, final String dnsAddress) {
+        this.ipAddress = ipAddress;
+        this.dnsAddress = dnsAddress;
+    }
+
+    /**
+     * Get the ip address.
+     *
+     * @return the ipAddress
+     */
+    public final String getIpAddress() {
+        return ipAddress;
+    }
+
+    /**
+     * Set the ip address.
+     *
+     * @param ipAddress the ipAddress to set
+     */
+    public final void setIpAddress(final String ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /**
+     * Get the dns address.
+     *
+     * @return the dnsAddress
+     */
+    public final String getDnsAddress() {
+        return dnsAddress;
+    }
+
+    /**
+     * Set the dns address.
+     *
+     * @param dnsAddress the dnsAddress to set
+     */
+    public final void setDnsAddress(final String dnsAddress) {
+        this.dnsAddress = dnsAddress;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(final Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof SubjectLocalityBean)) {
+            return false;
+        }
+
+        SubjectLocalityBean that = (SubjectLocalityBean) o;
+
+        if (ipAddress == null && that.ipAddress != null) {
+            return false;
+        } else if (ipAddress != null && !ipAddress.equals(that.ipAddress)) {
+            return false;
+        }
+
+        if (dnsAddress == null && that.dnsAddress != null) {
+            return false;
+        } else if (dnsAddress != null && !dnsAddress.equals(that.dnsAddress)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see java.lang.Object#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        int result = 0;
+        if (ipAddress != null) {
+            result = 31 * result + ipAddress.hashCode();
+        }
+        if (dnsAddress != null) {
+            result = 31 * result + dnsAddress.hashCode();
+        }
+
+        return result;
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/Version.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/Version.java
new file mode 100644
index 000000000..66e9d6c0f
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/bean/Version.java
@@ -0,0 +1,30 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.bean;
+
+
+/**
+ * The SAML Version
+ */
+public enum Version {
+
+    SAML_20, SAML_11, SAML_10;
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1ComponentBuilder.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1ComponentBuilder.java
new file mode 100644
index 000000000..44f24ff9e
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1ComponentBuilder.java
@@ -0,0 +1,626 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.builder;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.saml.OpenSAMLUtil;
+import org.apache.wss4j.common.saml.bean.ActionBean;
+import org.apache.wss4j.common.saml.bean.AdviceBean;
+import org.apache.wss4j.common.saml.bean.AttributeBean;
+import org.apache.wss4j.common.saml.bean.AttributeStatementBean;
+import org.apache.wss4j.common.saml.bean.AudienceRestrictionBean;
+import org.apache.wss4j.common.saml.bean.AuthDecisionStatementBean;
+import org.apache.wss4j.common.saml.bean.AuthenticationStatementBean;
+import org.apache.wss4j.common.saml.bean.ConditionsBean;
+import org.apache.wss4j.common.saml.bean.KeyInfoBean;
+import org.apache.wss4j.common.saml.bean.SubjectBean;
+import org.apache.wss4j.common.saml.bean.SubjectLocalityBean;
+import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.XMLObjectBuilderFactory;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.schema.XSString;
+import org.opensaml.core.xml.schema.impl.XSStringBuilder;
+import org.opensaml.saml.common.SAMLObjectBuilder;
+import org.opensaml.saml.common.SAMLVersion;
+import org.opensaml.saml.saml1.core.Action;
+import org.opensaml.saml.saml1.core.Advice;
+import org.opensaml.saml.saml1.core.Assertion;
+import org.opensaml.saml.saml1.core.AssertionIDReference;
+import org.opensaml.saml.saml1.core.Attribute;
+import org.opensaml.saml.saml1.core.AttributeStatement;
+import org.opensaml.saml.saml1.core.AttributeValue;
+import org.opensaml.saml.saml1.core.Audience;
+import org.opensaml.saml.saml1.core.AudienceRestrictionCondition;
+import org.opensaml.saml.saml1.core.AuthenticationStatement;
+import org.opensaml.saml.saml1.core.AuthorizationDecisionStatement;
+import org.opensaml.saml.saml1.core.Conditions;
+import org.opensaml.saml.saml1.core.ConfirmationMethod;
+import org.opensaml.saml.saml1.core.DecisionTypeEnumeration;
+import org.opensaml.saml.saml1.core.Evidence;
+import org.opensaml.saml.saml1.core.NameIdentifier;
+import org.opensaml.saml.saml1.core.Subject;
+import org.opensaml.saml.saml1.core.SubjectConfirmation;
+import org.opensaml.saml.saml1.core.SubjectLocality;
+import org.opensaml.security.credential.BasicCredential;
+import org.opensaml.security.x509.BasicX509Credential;
+import org.opensaml.xmlsec.keyinfo.impl.BasicKeyInfoGeneratorFactory;
+import org.opensaml.xmlsec.keyinfo.impl.X509KeyInfoGeneratorFactory;
+import org.opensaml.xmlsec.signature.KeyInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Class SAML1ComponentBuilder provides builder methods that can be used
+ * to construct SAML v1.1 statements using the OpenSaml library.
+ */
+public final class SAML1ComponentBuilder {
+
+    private static volatile SAMLObjectBuilder<Assertion> assertionV1Builder;
+
+    private static volatile SAMLObjectBuilder<Conditions> conditionsV1Builder;
+
+    private static volatile SAMLObjectBuilder<Advice> adviceV1Builder;
+
+    private static volatile SAMLObjectBuilder<AssertionIDReference> assertionIDReferenceBuilder;
+
+    private static volatile SAMLObjectBuilder<AudienceRestrictionCondition> audienceRestrictionV1Builder;
+
+    private static volatile SAMLObjectBuilder<Audience> audienceV1Builder;
+
+    private static volatile SAMLObjectBuilder<AuthenticationStatement> authenticationStatementV1Builder;
+
+    private static volatile SAMLObjectBuilder<Subject> subjectV1Builder;
+
+    private static volatile SAMLObjectBuilder<NameIdentifier> nameIdentifierV1Builder;
+
+    private static volatile SAMLObjectBuilder<SubjectConfirmation>
+        subjectConfirmationV1Builder;
+
+    private static volatile SAMLObjectBuilder<ConfirmationMethod> confirmationMethodV1Builder;
+
+    private static volatile SAMLObjectBuilder<AttributeStatement>
+        attributeStatementV1Builder;
+
+    private static volatile SAMLObjectBuilder<Attribute> attributeV1Builder;
+
+    private static volatile XSStringBuilder stringBuilder;
+
+    private static volatile SAMLObjectBuilder<AuthorizationDecisionStatement>
+        authorizationDecisionStatementV1Builder;
+
+    private static volatile SAMLObjectBuilder<Action> actionElementV1Builder;
+
+    private static volatile XMLObjectBuilderFactory builderFactory =
+        XMLObjectProviderRegistrySupport.getBuilderFactory();
+
+    private static volatile SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
+
+    private SAML1ComponentBuilder() {
+        // Complete
+    }
+
+    /**
+     * Create a new SAML 1.1 assertion
+     *
+     * @param issuer of type String
+     * @return A SAML 1.1 assertion
+     */
+    @SuppressWarnings("unchecked")
+    public static Assertion createSamlv1Assertion(String issuer) {
+        if (assertionV1Builder == null) {
+            assertionV1Builder = (SAMLObjectBuilder<Assertion>)
+                builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
+            if (assertionV1Builder == null) {
+                throw new IllegalStateException(
+                    "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml "
+                    + "engine prior using it"
+                );
+            }
+        }
+        Assertion assertion =
+            assertionV1Builder.buildObject(
+                Assertion.DEFAULT_ELEMENT_NAME,
+                Assertion.TYPE_NAME
+            );
+        assertion.setVersion(SAMLVersion.VERSION_11);
+        assertion.setIssuer(issuer);
+        assertion.setIssueInstant(Instant.now()); // now
+        assertion.setID(IDGenerator.generateID("_"));
+        return assertion;
+    }
+
+
+    /**
+     * Create a SAML Subject from a SubjectBean instance
+     *
+     * @param subjectBean A SubjectBean instance
+     * @return A Saml 1.1 subject
+     */
+    @SuppressWarnings("unchecked")
+    public static Subject createSaml1v1Subject(SubjectBean subjectBean)
+        throws org.opensaml.security.SecurityException, WSSecurityException {
+        if (subjectV1Builder == null) {
+            subjectV1Builder = (SAMLObjectBuilder<Subject>)
+                builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
+        }
+        if (nameIdentifierV1Builder == null) {
+            nameIdentifierV1Builder = (SAMLObjectBuilder<NameIdentifier>)
+                builderFactory.getBuilder(NameIdentifier.DEFAULT_ELEMENT_NAME);
+        }
+        if (subjectConfirmationV1Builder == null) {
+            subjectConfirmationV1Builder = (SAMLObjectBuilder<SubjectConfirmation>)
+                builderFactory.getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
+
+        }
+        if (confirmationMethodV1Builder == null) {
+            confirmationMethodV1Builder = (SAMLObjectBuilder<ConfirmationMethod>)
+                builderFactory.getBuilder(ConfirmationMethod.DEFAULT_ELEMENT_NAME);
+        }
+
+        Subject subject = subjectV1Builder.buildObject();
+        NameIdentifier nameIdentifier = nameIdentifierV1Builder.buildObject();
+        SubjectConfirmation subjectConfirmation = subjectConfirmationV1Builder.buildObject();
+        ConfirmationMethod confirmationMethod = confirmationMethodV1Builder.buildObject();
+
+        nameIdentifier.setNameQualifier(subjectBean.getSubjectNameQualifier());
+        nameIdentifier.setValue(subjectBean.getSubjectName());
+        nameIdentifier.setFormat(subjectBean.getSubjectNameIDFormat());
+        String confirmationMethodStr = subjectBean.getSubjectConfirmationMethod();
+
+        if (confirmationMethodStr == null) {
+            confirmationMethodStr = SAML1Constants.CONF_SENDER_VOUCHES;
+        }
+
+        confirmationMethod.setURI(confirmationMethodStr);
+        subjectConfirmation.getConfirmationMethods().add(confirmationMethod);
+        if (subjectBean.getKeyInfo() != null) {
+            KeyInfo keyInfo = createKeyInfo(subjectBean.getKeyInfo());
+            subjectConfirmation.setKeyInfo(keyInfo);
+        }
+        subject.setNameIdentifier(nameIdentifier);
+        subject.setSubjectConfirmation(subjectConfirmation);
+
+        return subject;
+    }
+
+    /**
+     * Create an Opensaml KeyInfo object from the parameters
+     * @param keyInfo the KeyInfo bean from which to extract security credentials
+     * @return the KeyInfo object
+     * @throws org.opensaml.security.SecurityException
+     */
+    public static KeyInfo createKeyInfo(KeyInfoBean keyInfo)
+        throws org.opensaml.security.SecurityException, WSSecurityException {
+        if (keyInfo.getElement() != null) {
+            return (KeyInfo)OpenSAMLUtil.fromDom(keyInfo.getElement());
+        } else {
+            // Set the certificate or public key
+            if (keyInfo.getCertificate() != null) {
+                BasicCredential keyInfoCredential = new BasicX509Credential(keyInfo.getCertificate());
+
+                // Configure how to emit the certificate
+                X509KeyInfoGeneratorFactory kiFactory = new X509KeyInfoGeneratorFactory();
+                KeyInfoBean.CERT_IDENTIFIER certIdentifier = keyInfo.getCertIdentifer();
+                switch (certIdentifier) {
+                    case X509_CERT:
+                        kiFactory.setEmitEntityCertificate(true);
+                        break;
+                    case KEY_VALUE:
+                        kiFactory.setEmitPublicKeyValue(true);
+                        break;
+                    case X509_ISSUER_SERIAL:
+                        kiFactory.setEmitX509IssuerSerial(true);
+                        break;
+                }
+                return kiFactory.newInstance().generate(keyInfoCredential);
+
+            } else if (keyInfo.getPublicKey() != null) {
+                BasicCredential keyInfoCredential = new BasicCredential(keyInfo.getPublicKey());
+                BasicKeyInfoGeneratorFactory kiFactory = new BasicKeyInfoGeneratorFactory();
+                kiFactory.setEmitPublicKeyValue(true);
+                return kiFactory.newInstance().generate(keyInfoCredential);
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Create a Conditions object
+     *
+     * @param conditionsBean A ConditionsBean object
+     * @return a Conditions object
+     */
+    @SuppressWarnings("unchecked")
+    public static Conditions createSamlv1Conditions(ConditionsBean conditionsBean) {
+        if (conditionsV1Builder == null) {
+            conditionsV1Builder = (SAMLObjectBuilder<Conditions>)
+                builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
+
+        }
+        Conditions conditions = conditionsV1Builder.buildObject();
+
+        if (conditionsBean == null) {
+            Instant newNotBefore = Instant.now();
+            conditions.setNotBefore(newNotBefore);
+            conditions.setNotOnOrAfter(newNotBefore.plus(Duration.ofMinutes(5)));
+            return conditions;
+        }
+
+        long tokenPeriodSeconds = conditionsBean.getTokenPeriodSeconds();
+        Instant notBefore = conditionsBean.getNotBefore();
+        Instant notAfter = conditionsBean.getNotAfter();
+
+        if (notBefore != null && notAfter != null) {
+            if (notBefore.isAfter(notAfter)) {
+                throw new IllegalStateException(
+                    "The value of notBefore may not be after the value of notAfter"
+                );
+            }
+            conditions.setNotBefore(notBefore);
+            conditions.setNotOnOrAfter(notAfter);
+        } else {
+            Instant newNotBefore = Instant.now();
+            conditions.setNotBefore(newNotBefore);
+            if (tokenPeriodSeconds <= 0) {
+                tokenPeriodSeconds = 5L * 60L;
+            }
+            Instant notOnOrAfter = newNotBefore.plusSeconds(tokenPeriodSeconds);
+            conditions.setNotOnOrAfter(notOnOrAfter);
+        }
+
+        if (conditionsBean.getAudienceRestrictions() != null
+            && !conditionsBean.getAudienceRestrictions().isEmpty()) {
+            for (AudienceRestrictionBean audienceRestrictionBean
+                    : conditionsBean.getAudienceRestrictions()) {
+                AudienceRestrictionCondition audienceRestriction =
+                    createSamlv1AudienceRestriction(audienceRestrictionBean);
+                conditions.getAudienceRestrictionConditions().add(audienceRestriction);
+            }
+        }
+
+        return conditions;
+    }
+
+    /**
+     * Create a Advice object
+     *
+     * @param adviceBean A AdviceBean object
+     * @return a Advice object
+     * @throws WSSecurityException
+     */
+    @SuppressWarnings("unchecked")
+    public static Advice createAdvice(AdviceBean adviceBean) throws WSSecurityException {
+        if (adviceV1Builder == null) {
+            adviceV1Builder = (SAMLObjectBuilder<Advice>)
+                builderFactory.getBuilder(Advice.DEFAULT_ELEMENT_NAME);
+        }
+
+        Advice advice = adviceV1Builder.buildObject();
+
+        if (!adviceBean.getIdReferences().isEmpty()) {
+            if (assertionIDReferenceBuilder == null) {
+                assertionIDReferenceBuilder = (SAMLObjectBuilder<AssertionIDReference>)
+                    builderFactory.getBuilder(AssertionIDReference.DEFAULT_ELEMENT_NAME);
+            }
+
+            for (String ref : adviceBean.getIdReferences()) {
+                AssertionIDReference assertionIdReference =
+                    assertionIDReferenceBuilder.buildObject();
+                assertionIdReference.setValue(ref);
+                advice.getAssertionIDReferences().add(assertionIdReference);
+            }
+        }
+
+        if (!adviceBean.getAssertions().isEmpty()) {
+            for (Element assertionElement : adviceBean.getAssertions()) {
+                XMLObject xmlObject = OpenSAMLUtil.fromDom(assertionElement);
+                if (xmlObject instanceof Assertion) {
+                    Assertion assertion = (Assertion)xmlObject;
+                    advice.getAssertions().add(assertion);
+                }
+            }
+        }
+
+        return advice;
+    }
+
+    /**
+     * Create an AudienceRestrictionCondition object
+     *
+     * @param audienceRestrictionBean of type AudienceRestrictionBean
+     * @return an AudienceRestrictionCondition object
+     */
+    @SuppressWarnings("unchecked")
+    public static AudienceRestrictionCondition
+    createSamlv1AudienceRestriction(AudienceRestrictionBean audienceRestrictionBean) {
+        if (audienceRestrictionV1Builder == null) {
+            audienceRestrictionV1Builder = (SAMLObjectBuilder<AudienceRestrictionCondition>)
+                builderFactory.getBuilder(AudienceRestrictionCondition.DEFAULT_ELEMENT_NAME);
+        }
+        if (audienceV1Builder == null) {
+            audienceV1Builder = (SAMLObjectBuilder<Audience>)
+                builderFactory.getBuilder(Audience.DEFAULT_ELEMENT_NAME);
+        }
+
+        AudienceRestrictionCondition audienceRestriction =
+            audienceRestrictionV1Builder.buildObject();
+
+        for (String audienceURI : audienceRestrictionBean.getAudienceURIs()) {
+            Audience audience = audienceV1Builder.buildObject();
+            audience.setURI(audienceURI);
+            audienceRestriction.getAudiences().add(audience);
+        }
+        return audienceRestriction;
+    }
+
+    /**
+     * Create SAML 1.1 authentication statement(s)
+     *
+     * @param authBeans A list of AuthenticationStatementBean objects
+     * @return a list of SAML 1.1 authentication statement(s)
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AuthenticationStatement> createSamlv1AuthenticationStatement(
+        List<AuthenticationStatementBean> authBeans
+    ) throws org.opensaml.security.SecurityException, WSSecurityException {
+        List<AuthenticationStatement> authenticationStatements = new ArrayList<>();
+
+        if (authenticationStatementV1Builder == null) {
+            authenticationStatementV1Builder = (SAMLObjectBuilder<AuthenticationStatement>)
+                builderFactory.getBuilder(AuthenticationStatement.DEFAULT_ELEMENT_NAME);
+        }
+        if (subjectLocalityBuilder == null) {
+            subjectLocalityBuilder = (SAMLObjectBuilder<SubjectLocality>)
+                builderFactory.getBuilder(SubjectLocality.DEFAULT_ELEMENT_NAME);
+        }
+
+        if (authBeans != null && !authBeans.isEmpty()) {
+            for (AuthenticationStatementBean statementBean : authBeans) {
+                AuthenticationStatement authenticationStatement =
+                    authenticationStatementV1Builder.buildObject(
+                        AuthenticationStatement.DEFAULT_ELEMENT_NAME,
+                        AuthenticationStatement.TYPE_NAME
+                    );
+                Subject authSubject =
+                    SAML1ComponentBuilder.createSaml1v1Subject(statementBean.getSubject());
+                authenticationStatement.setSubject(authSubject);
+
+                if (statementBean.getAuthenticationInstant() != null) {
+                    authenticationStatement.setAuthenticationInstant(
+                        statementBean.getAuthenticationInstant()
+                    );
+                } else {
+                    authenticationStatement.setAuthenticationInstant(Instant.now());
+                }
+
+                authenticationStatement.setAuthenticationMethod(
+                    transformAuthenticationMethod(statementBean.getAuthenticationMethod())
+                );
+
+                SubjectLocalityBean subjectLocalityBean = statementBean.getSubjectLocality();
+                if (subjectLocalityBean != null) {
+                    SubjectLocality subjectLocality = subjectLocalityBuilder.buildObject();
+                    subjectLocality.setDNSAddress(subjectLocalityBean.getDnsAddress());
+                    subjectLocality.setIPAddress(subjectLocalityBean.getIpAddress());
+
+                    authenticationStatement.setSubjectLocality(subjectLocality);
+                }
+
+                authenticationStatements.add(authenticationStatement);
+            }
+        }
+
+        return authenticationStatements;
+    }
+
+    /**
+     * Method transformAuthenticationMethod transforms the user-supplied authentication method
+     * value into one of the supported specification-compliant values.
+     *
+     * @param sourceMethod of type String
+     * @return String
+     */
+    private static String transformAuthenticationMethod(String sourceMethod) {
+        String transformedMethod = "";
+
+        if ("Password".equals(sourceMethod)) {
+            transformedMethod = SAML1Constants.AUTH_METHOD_PASSWORD;
+        } else if (sourceMethod != null && sourceMethod.length() != 0) {
+            return sourceMethod;
+        }
+
+        return transformedMethod;
+    }
+
+    /**
+     * Create SAML 1.1 attribute statement(s)
+     *
+     * @param attributeData A list of AttributeStatementBean instances
+     * @return a list of SAML 1.1 attribute statement(s)
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AttributeStatement> createSamlv1AttributeStatement(
+        List<AttributeStatementBean> attributeData
+    ) throws org.opensaml.security.SecurityException, WSSecurityException {
+        if (attributeStatementV1Builder == null) {
+            attributeStatementV1Builder = (SAMLObjectBuilder<AttributeStatement>)
+                builderFactory.getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
+        }
+
+        List<AttributeStatement> attributeStatements = new ArrayList<>();
+
+        if (attributeData != null && !attributeData.isEmpty()) {
+            for (AttributeStatementBean statementBean : attributeData) {
+                // Create the attribute statementBean and set the subject
+                AttributeStatement attributeStatement = attributeStatementV1Builder.buildObject();
+                Subject attributeSubject =
+                    SAML1ComponentBuilder.createSaml1v1Subject(statementBean.getSubject());
+                attributeStatement.setSubject(attributeSubject);
+                // Add the individual attributes
+                for (AttributeBean values : statementBean.getSamlAttributes()) {
+                    List<Object> attributeValues = values.getAttributeValues();
+
+                    Attribute samlAttribute =
+                        createSamlv1Attribute(
+                            values.getSimpleName(),
+                            values.getQualifiedName(),
+                            attributeValues
+                        );
+                    attributeStatement.getAttributes().add(samlAttribute);
+                }
+                // Add the completed attribute statementBean to the collection
+                attributeStatements.add(attributeStatement);
+            }
+        }
+
+        return attributeStatements;
+    }
+
+    /**
+     * Create a SAML 1.1 attribute
+     *
+     * @param attributeName the Attribute Name
+     * @param attributeUrn the Attribute Qualified Name
+     * @param values the Attribute Values
+     * @return a SAML 1.1 attribute
+     */
+    @SuppressWarnings("unchecked")
+    public static Attribute createSamlv1Attribute(
+        String attributeName,
+        String attributeUrn,
+        List<Object> values
+    ) {
+        if (attributeV1Builder == null) {
+            attributeV1Builder = (SAMLObjectBuilder<Attribute>)
+                builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
+        }
+        if (stringBuilder == null) {
+            stringBuilder = (XSStringBuilder)builderFactory.getBuilder(XSString.TYPE_NAME);
+        }
+
+        Attribute attribute = attributeV1Builder.buildObject();
+        attribute.setAttributeName(attributeName);
+        attribute.setAttributeNamespace(attributeUrn);
+
+        for (Object value : values) {
+            if (value instanceof String) {
+                XSString attribute1 =
+                    stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
+                attribute1.setValue((String)value);
+                attribute.getAttributeValues().add(attribute1);
+            } else if (value instanceof XMLObject) {
+                attribute.getAttributeValues().add((XMLObject)value);
+            }
+        }
+
+        return attribute;
+    }
+
+    /**
+     * Create SAML 1.1 Authorization Decision Statement(s)
+     *
+     * @param decisionData        of type List<AuthDecisionStatementBean>
+     * @return a list of SAML 1.1 Authorization Decision Statement(s)
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AuthorizationDecisionStatement> createSamlv1AuthorizationDecisionStatement(
+            List<AuthDecisionStatementBean> decisionData)
+        throws org.opensaml.security.SecurityException, WSSecurityException {
+        List<AuthorizationDecisionStatement> authDecisionStatements = new ArrayList<>();
+        if (authorizationDecisionStatementV1Builder == null) {
+            authorizationDecisionStatementV1Builder =
+                (SAMLObjectBuilder<AuthorizationDecisionStatement>)
+                    builderFactory.getBuilder(AuthorizationDecisionStatement.DEFAULT_ELEMENT_NAME);
+
+        }
+
+        if (decisionData != null && !decisionData.isEmpty()) {
+            for (AuthDecisionStatementBean decisionStatementBean : decisionData) {
+                AuthorizationDecisionStatement authDecision =
+                    authorizationDecisionStatementV1Builder.buildObject();
+                Subject authDecisionSubject =
+                    SAML1ComponentBuilder.createSaml1v1Subject(decisionStatementBean.getSubject());
+                authDecision.setSubject(authDecisionSubject);
+
+                authDecision.setResource(decisionStatementBean.getResource());
+                authDecision.setDecision(transformDecisionType(decisionStatementBean.getDecision()));
+
+                for (ActionBean actionBean : decisionStatementBean.getActions()) {
+                    Action actionElement = createSamlv1Action(actionBean);
+                    authDecision.getActions().add(actionElement);
+                }
+
+                if (decisionStatementBean.getEvidence() instanceof Evidence) {
+                    authDecision.setEvidence((Evidence)decisionStatementBean.getEvidence());
+                }
+
+                authDecisionStatements.add(authDecision);
+            }
+        }
+
+        return authDecisionStatements;
+    }
+
+    /**
+     * Create an Action object
+     *
+     * @param actionBean of type SamlAction
+     * @return an Action object
+     */
+    @SuppressWarnings("unchecked")
+    public static Action createSamlv1Action(ActionBean actionBean) {
+        if (actionElementV1Builder == null) {
+            actionElementV1Builder = (SAMLObjectBuilder<Action>)
+                builderFactory.getBuilder(Action.DEFAULT_ELEMENT_NAME);
+        }
+
+        Action actionElement = actionElementV1Builder.buildObject();
+        actionElement.setNamespace(actionBean.getActionNamespace());
+        actionElement.setValue(actionBean.getContents());
+
+        return actionElement;
+    }
+
+    /**
+     * Transform a DecisionType
+     *
+     * @param decision of type Decision
+     * @return DecisionTypeEnumeration
+     */
+    private static DecisionTypeEnumeration transformDecisionType(
+        AuthDecisionStatementBean.Decision decision
+    ) {
+        DecisionTypeEnumeration decisionTypeEnum = DecisionTypeEnumeration.DENY;
+        if (decision.equals(AuthDecisionStatementBean.Decision.PERMIT)) {
+            decisionTypeEnum = DecisionTypeEnumeration.PERMIT;
+        } else if (decision.equals(AuthDecisionStatementBean.Decision.INDETERMINATE)) {
+            decisionTypeEnum = DecisionTypeEnumeration.INDETERMINATE;
+        }
+
+        return decisionTypeEnum;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1Constants.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1Constants.java
new file mode 100644
index 000000000..67c0bdd41
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML1Constants.java
@@ -0,0 +1,147 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.builder;
+
+
+/**
+ * Class SAML1Constants provides static constant definitions associated with
+ * the SAML v1.x specification.
+ */
+public final class SAML1Constants {
+
+    //
+    // NAME ID FORMAT
+    //
+
+    public static final String NAMEID_FORMAT_UNSPECIFIED =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";
+
+    public static final String NAMEID_FORMAT_EMAIL_ADDRESS =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";
+
+    public static final String NAMEID_FORMAT_X509_SUBJECT_NAME =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName";
+
+    public static final String NAMEID_FORMAT_WINDOWS_DQN =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName";
+
+    //
+    // SUBJECT CONFIRMATION
+    //
+
+    /**
+     * Assertion Bearer Confirmation Method Identifier
+     */
+    public static final String CONF_BEARER =
+        "urn:oasis:names:tc:SAML:1.0:cm:bearer";
+
+    /**
+     * Holder of Key Confirmation Method Identifier
+     */
+    public static final String CONF_HOLDER_KEY =
+        "urn:oasis:names:tc:SAML:1.0:cm:holder-of-key";
+
+    /**
+     * Sender Vouches Confirmation Method Identifier
+     */
+    public static final String CONF_SENDER_VOUCHES =
+        "urn:oasis:names:tc:SAML:1.0:cm:sender-vouches";
+
+    //
+    // AUTH METHOD
+    //
+
+    /**
+     * The authentication was performed by means of a password.
+     */
+    public static final String AUTH_METHOD_PASSWORD =
+        "urn:oasis:names:tc:SAML:1.0:am:password";
+
+    /**
+     * The authentication was performed by means of the Kerberos protocol [RFC 1510],
+     * an instantiation of the Needham-Schroeder symmetric key authentication mechanism [Needham78].
+     */
+    public static final String AUTH_METHOD_KERBEROS = "urn:ietf:rfc:1510";
+
+    /**
+     * The authentication was performed by means of Secure Remote Password protocol as specified in
+     * [RFC 2945].
+     */
+    public static final String AUTH_METHOD_SRP = "urn:ietf:rfc:2945";
+
+    /**
+     * The authentication was performed by means of an unspecified hardware token.
+     */
+    public static final String AUTH_METHOD_HARDWARE_TOKEN =
+        "urn:oasis:names:tc:SAML:1.0:am:HardwareToken";
+
+    /**
+     * The authentication was performed using either the SSL or TLS protocol with certificate
+     * based client authentication. TLS is described in [RFC 2246].
+     */
+    public static final String AUTH_METHOD_TLS_CLIENT = "urn:ietf:rfc:2246";
+
+    /**
+     * The authentication was performed by some (unspecified) mechanism on a key authenticated by
+     * means of an X.509 PKI [X.500][PKIX]. It may have been one of the mechanisms for which a more
+     * specific identifier has been defined.
+     */
+    public static final String AUTH_METHOD_X509 =
+        "urn:oasis:names:tc:SAML:1.0:am:X509-PKI";
+
+    /**
+     * The authentication was performed by some (unspecified) mechanism on a key authenticated by
+     * means of a PGP web of trust [PGP]. It may have been one of the mechanisms for which a more
+     * specific identifier has been defined.
+     */
+    public static final String AUTH_METHOD_PGP =
+        "urn:oasis:names:tc:SAML:1.0:am:PGP";
+
+    /**
+     * The authentication was performed by some (unspecified) mechanism on a key authenticated by
+     * means of a SPKI PKI [SPKI]. It may have been one of the mechanisms for which a more specific
+     * identifier has been defined.
+     */
+    public static final String AUTH_METHOD_SPKI =
+        "urn:oasis:names:tc:SAML:1.0:am:SPKI";
+
+    /**
+     * The authentication was performed by some (unspecified) mechanism on a key authenticated by
+     * means of a XKMS trust service [XKMS]. It may have been one of the mechanisms for which a more
+     * specific identifier has been defined.
+     */
+    public static final String AUTH_METHOD_XKMS =
+        "urn:oasis:names:tc:SAML:1.0:am:XKMS";
+
+    /**
+     * The authentication was performed by means of an XML digital signature [RFC 3075].
+     */
+    public static final String AUTH_METHOD_DSIG = "urn:ietf:rfc:3075";
+
+    /**
+     * The authentication was performed by an unspecified means.
+     */
+    public static final String AUTH_METHOD_UNSPECIFIED =
+        "urn:oasis:names:tc:SAML:1.0:am:unspecified";
+
+    private SAML1Constants() {
+        // Complete
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2ComponentBuilder.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2ComponentBuilder.java
new file mode 100644
index 000000000..bff03d14d
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2ComponentBuilder.java
@@ -0,0 +1,891 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.builder;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.saml.OpenSAMLUtil;
+import org.apache.wss4j.common.saml.bean.ActionBean;
+import org.apache.wss4j.common.saml.bean.AdviceBean;
+import org.apache.wss4j.common.saml.bean.AttributeBean;
+import org.apache.wss4j.common.saml.bean.AttributeStatementBean;
+import org.apache.wss4j.common.saml.bean.AudienceRestrictionBean;
+import org.apache.wss4j.common.saml.bean.AuthDecisionStatementBean;
+import org.apache.wss4j.common.saml.bean.AuthenticationStatementBean;
+import org.apache.wss4j.common.saml.bean.ConditionsBean;
+import org.apache.wss4j.common.saml.bean.DelegateBean;
+import org.apache.wss4j.common.saml.bean.KeyInfoBean;
+import org.apache.wss4j.common.saml.bean.NameIDBean;
+import org.apache.wss4j.common.saml.bean.ProxyRestrictionBean;
+import org.apache.wss4j.common.saml.bean.SubjectBean;
+import org.apache.wss4j.common.saml.bean.SubjectConfirmationDataBean;
+import org.apache.wss4j.common.saml.bean.SubjectLocalityBean;
+import org.apache.xml.security.stax.impl.util.IDGenerator;
+import org.opensaml.core.xml.XMLObject;
+import org.opensaml.core.xml.XMLObjectBuilderFactory;
+import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
+import org.opensaml.core.xml.schema.XSString;
+import org.opensaml.core.xml.schema.impl.XSStringBuilder;
+import org.opensaml.saml.common.SAMLObjectBuilder;
+import org.opensaml.saml.common.SAMLVersion;
+import org.opensaml.saml.ext.saml2delrestrict.Delegate;
+import org.opensaml.saml.ext.saml2delrestrict.DelegationRestrictionType;
+import org.opensaml.saml.saml2.core.Action;
+import org.opensaml.saml.saml2.core.Advice;
+import org.opensaml.saml.saml2.core.Assertion;
+import org.opensaml.saml.saml2.core.AssertionIDRef;
+import org.opensaml.saml.saml2.core.AssertionURIRef;
+import org.opensaml.saml.saml2.core.Attribute;
+import org.opensaml.saml.saml2.core.AttributeStatement;
+import org.opensaml.saml.saml2.core.AttributeValue;
+import org.opensaml.saml.saml2.core.Audience;
+import org.opensaml.saml.saml2.core.AudienceRestriction;
+import org.opensaml.saml.saml2.core.AuthnContext;
+import org.opensaml.saml.saml2.core.AuthnContextClassRef;
+import org.opensaml.saml.saml2.core.AuthnStatement;
+import org.opensaml.saml.saml2.core.AuthzDecisionStatement;
+import org.opensaml.saml.saml2.core.Conditions;
+import org.opensaml.saml.saml2.core.DecisionTypeEnumeration;
+import org.opensaml.saml.saml2.core.Evidence;
+import org.opensaml.saml.saml2.core.Issuer;
+import org.opensaml.saml.saml2.core.KeyInfoConfirmationDataType;
+import org.opensaml.saml.saml2.core.NameID;
+import org.opensaml.saml.saml2.core.OneTimeUse;
+import org.opensaml.saml.saml2.core.ProxyRestriction;
+import org.opensaml.saml.saml2.core.Subject;
+import org.opensaml.saml.saml2.core.SubjectConfirmation;
+import org.opensaml.saml.saml2.core.SubjectConfirmationData;
+import org.opensaml.saml.saml2.core.SubjectLocality;
+import org.opensaml.xmlsec.signature.KeyInfo;
+import org.w3c.dom.Element;
+
+/**
+ * Class SAML2ComponentBuilder provides builder methods that can be used
+ * to construct SAML v2.0 statements using the OpenSaml library.
+ */
+public final class SAML2ComponentBuilder {
+
+    private static final transient org.slf4j.Logger LOG =
+            org.slf4j.LoggerFactory.getLogger(SAML2ComponentBuilder.class);
+
+    private static volatile SAMLObjectBuilder<Assertion> assertionBuilder;
+
+    private static volatile SAMLObjectBuilder<Issuer> issuerBuilder;
+
+    private static volatile SAMLObjectBuilder<Subject> subjectBuilder;
+
+    private static volatile SAMLObjectBuilder<NameID> nameIdBuilder;
+
+    private static volatile SAMLObjectBuilder<SubjectConfirmation> subjectConfirmationBuilder;
+
+    private static volatile SAMLObjectBuilder<OneTimeUse> oneTimeUseBuilder;
+
+    private static volatile SAMLObjectBuilder<ProxyRestriction> proxyRestrictionBuilder;
+
+    private static volatile SAMLObjectBuilder<Conditions> conditionsBuilder;
+
+    private static volatile SAMLObjectBuilder<Advice> adviceBuilder;
+
+    private static volatile SAMLObjectBuilder<AssertionIDRef> assertionIDRefBuilder;
+
+    private static volatile SAMLObjectBuilder<AssertionURIRef> assertionURIRefBuilder;
+
+    private static volatile SAMLObjectBuilder<SubjectConfirmationData> subjectConfirmationDataBuilder;
+
+    private static volatile SAMLObjectBuilder<KeyInfoConfirmationDataType> keyInfoConfirmationDataBuilder;
+
+    private static volatile SAMLObjectBuilder<AuthnStatement> authnStatementBuilder;
+
+    private static volatile SAMLObjectBuilder<AuthnContext> authnContextBuilder;
+
+    private static volatile SAMLObjectBuilder<AuthnContextClassRef> authnContextClassRefBuilder;
+
+    private static volatile SAMLObjectBuilder<AttributeStatement> attributeStatementBuilder;
+
+    private static volatile SAMLObjectBuilder<Attribute> attributeBuilder;
+
+    private static volatile XSStringBuilder stringBuilder;
+
+    private static volatile SAMLObjectBuilder<AudienceRestriction> audienceRestrictionBuilder;
+
+    private static volatile SAMLObjectBuilder<DelegationRestrictionType> delegationRestrictionBuilder;
+
+    private static volatile SAMLObjectBuilder<Audience> audienceBuilder;
+
+    private static volatile SAMLObjectBuilder<Delegate> delegateBuilder;
+
+    private static volatile SAMLObjectBuilder<AuthzDecisionStatement> authorizationDecisionStatementBuilder;
+
+    private static volatile SAMLObjectBuilder<Action> actionElementBuilder;
+
+    private static volatile XMLObjectBuilderFactory builderFactory =
+        XMLObjectProviderRegistrySupport.getBuilderFactory();
+
+    private static volatile SAMLObjectBuilder<SubjectLocality> subjectLocalityBuilder;
+
+    private SAML2ComponentBuilder() {
+        // Complete
+    }
+
+    /**
+     * Create a SAML 2 assertion
+     *
+     * @return a SAML 2 assertion
+     */
+    @SuppressWarnings("unchecked")
+    public static Assertion createAssertion() {
+        if (assertionBuilder == null) {
+            assertionBuilder = (SAMLObjectBuilder<Assertion>)
+                builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
+            if (assertionBuilder == null) {
+                throw new IllegalStateException(
+                    "OpenSaml engine not initialized. Please make sure to initialize the OpenSaml engine "
+                    + "prior using it"
+                );
+            }
+        }
+        Assertion assertion =
+            assertionBuilder.buildObject(Assertion.DEFAULT_ELEMENT_NAME, Assertion.TYPE_NAME);
+        assertion.setID(IDGenerator.generateID("_"));
+        assertion.setVersion(SAMLVersion.VERSION_20);
+        assertion.setIssueInstant(Instant.now());
+        return assertion;
+    }
+
+    /**
+     * Create an Issuer object
+     *
+     * @param issuerValue of type String
+     * @param issuerFormat of type String
+     * @param issuerQualifier of type String
+     * @return an Issuer object
+     */
+    @SuppressWarnings("unchecked")
+    public static Issuer createIssuer(String issuerValue, String issuerFormat, String issuerQualifier) {
+        if (issuerBuilder == null) {
+            issuerBuilder = (SAMLObjectBuilder<Issuer>)
+                builderFactory.getBuilder(Issuer.DEFAULT_ELEMENT_NAME);
+
+        }
+        Issuer issuer = issuerBuilder.buildObject();
+        //
+        // The SAML authority that is making the claim(s) in the assertion. The issuer SHOULD
+        // be unambiguous to the intended relying parties.
+        issuer.setValue(issuerValue);
+        issuer.setFormat(issuerFormat);
+        issuer.setNameQualifier(issuerQualifier);
+        return issuer;
+    }
+
+    /**
+     * Create a Conditions object
+     *
+     * @param conditionsBean A ConditionsBean object
+     * @return a Conditions object
+     */
+    @SuppressWarnings("unchecked")
+    public static Conditions createConditions(ConditionsBean conditionsBean) {
+        if (conditionsBuilder == null) {
+            conditionsBuilder = (SAMLObjectBuilder<Conditions>)
+                builderFactory.getBuilder(Conditions.DEFAULT_ELEMENT_NAME);
+        }
+
+        Conditions conditions = conditionsBuilder.buildObject();
+
+        if (conditionsBean == null) {
+            Instant newNotBefore = Instant.now();
+            conditions.setNotBefore(newNotBefore);
+            conditions.setNotOnOrAfter(newNotBefore.plus(Duration.ofMinutes(5)));
+            return conditions;
+        }
+
+        long tokenPeriodSeconds = conditionsBean.getTokenPeriodSeconds();
+        Instant notBefore = conditionsBean.getNotBefore();
+        Instant notAfter = conditionsBean.getNotAfter();
+
+        if (notBefore != null && notAfter != null) {
+            if (notBefore.isAfter(notAfter)) {
+                throw new IllegalStateException(
+                    "The value of notBefore may not be after the value of notAfter"
+                );
+            }
+            conditions.setNotBefore(notBefore);
+            conditions.setNotOnOrAfter(notAfter);
+        } else {
+            Instant newNotBefore = Instant.now();
+            conditions.setNotBefore(newNotBefore);
+            if (tokenPeriodSeconds <= 0) {
+                tokenPeriodSeconds = 5L * 60L;
+            }
+            Instant notOnOrAfter = newNotBefore.plusSeconds(tokenPeriodSeconds);
+            conditions.setNotOnOrAfter(notOnOrAfter);
+        }
+
+        if (conditionsBean.getAudienceRestrictions() != null
+            && !conditionsBean.getAudienceRestrictions().isEmpty()) {
+            for (AudienceRestrictionBean audienceRestrictionBean
+                : conditionsBean.getAudienceRestrictions()) {
+                AudienceRestriction audienceRestriction =
+                        createAudienceRestriction(audienceRestrictionBean);
+                conditions.getAudienceRestrictions().add(audienceRestriction);
+            }
+        }
+
+        if (conditionsBean.isOneTimeUse()) {
+            conditions.getConditions().add(createOneTimeUse());
+        }
+
+        if (conditionsBean.getProxyRestriction() != null) {
+            conditions.getConditions().add(createProxyRestriction(conditionsBean.getProxyRestriction()));
+        }
+
+        if (conditionsBean.getDelegates() != null && !conditionsBean.getDelegates().isEmpty()) {
+            DelegationRestrictionType delegationRestriction =
+                createDelegationRestriction(conditionsBean.getDelegates());
+            conditions.getConditions().add(delegationRestriction);
+        }
+
+        return conditions;
+    }
+
+    /**
+     * Create a Advice object
+     *
+     * @param adviceBean A AdviceBean object
+     * @return a Advice object
+     * @throws WSSecurityException
+     */
+    @SuppressWarnings("unchecked")
+    public static Advice createAdvice(AdviceBean adviceBean) throws WSSecurityException {
+        if (adviceBuilder == null) {
+            adviceBuilder = (SAMLObjectBuilder<Advice>)
+                builderFactory.getBuilder(Advice.DEFAULT_ELEMENT_NAME);
+        }
+
+        Advice advice = adviceBuilder.buildObject();
+
+        if (!adviceBean.getIdReferences().isEmpty()) {
+            if (assertionIDRefBuilder == null) {
+                assertionIDRefBuilder = (SAMLObjectBuilder<AssertionIDRef>)
+                    builderFactory.getBuilder(AssertionIDRef.DEFAULT_ELEMENT_NAME);
+            }
+
+            for (String ref : adviceBean.getIdReferences()) {
+                AssertionIDRef assertionIdRef = assertionIDRefBuilder.buildObject();
+                assertionIdRef.setValue(ref);
+                advice.getAssertionIDReferences().add(assertionIdRef);
+            }
+        }
+
+        if (!adviceBean.getUriReferences().isEmpty()) {
+            if (assertionURIRefBuilder == null) {
+                assertionURIRefBuilder = (SAMLObjectBuilder<AssertionURIRef>)
+                    builderFactory.getBuilder(AssertionURIRef.DEFAULT_ELEMENT_NAME);
+            }
+
+            for (String ref : adviceBean.getUriReferences()) {
+                AssertionURIRef assertionURIRef = assertionURIRefBuilder.buildObject();
+                assertionURIRef.setURI(ref);
+                advice.getAssertionURIReferences().add(assertionURIRef);
+            }
+        }
+
+        if (!adviceBean.getAssertions().isEmpty()) {
+            for (Element assertionElement : adviceBean.getAssertions()) {
+                XMLObject xmlObject = OpenSAMLUtil.fromDom(assertionElement);
+                if (xmlObject instanceof Assertion) {
+                    Assertion assertion = (Assertion)xmlObject;
+                    advice.getAssertions().add(assertion);
+                }
+            }
+        }
+
+        return advice;
+    }
+
+    /**
+     * Create an AudienceRestriction object
+     *
+     * @param audienceRestrictionBean of type AudienceRestrictionBean
+     * @return an AudienceRestriction object
+     */
+    @SuppressWarnings("unchecked")
+    public static AudienceRestriction createAudienceRestriction(
+        AudienceRestrictionBean audienceRestrictionBean
+    ) {
+        if (audienceRestrictionBuilder == null) {
+            audienceRestrictionBuilder = (SAMLObjectBuilder<AudienceRestriction>)
+                builderFactory.getBuilder(AudienceRestriction.DEFAULT_ELEMENT_NAME);
+        }
+        if (audienceBuilder == null) {
+            audienceBuilder = (SAMLObjectBuilder<Audience>)
+                builderFactory.getBuilder(Audience.DEFAULT_ELEMENT_NAME);
+        }
+
+        AudienceRestriction audienceRestriction = audienceRestrictionBuilder.buildObject();
+
+        for (String audienceURI : audienceRestrictionBean.getAudienceURIs()) {
+            Audience audience = audienceBuilder.buildObject();
+            audience.setURI(audienceURI);
+            audienceRestriction.getAudiences().add(audience);
+        }
+        return audienceRestriction;
+    }
+
+    /**
+     * Create an DelegationRestrictionType object
+     *
+     * @param delegates of type List<DelegateBean>
+     * @return a DelegationRestrictionType object
+     */
+    @SuppressWarnings("unchecked")
+    public static DelegationRestrictionType createDelegationRestriction(
+        List<DelegateBean> delegates
+    ) {
+        if (delegationRestrictionBuilder == null) {
+            delegationRestrictionBuilder = (SAMLObjectBuilder<DelegationRestrictionType>)
+                builderFactory.getBuilder(DelegationRestrictionType.TYPE_NAME);
+        }
+        DelegationRestrictionType delegationRestriction = delegationRestrictionBuilder.buildObject();
+
+        if (delegateBuilder == null) {
+            delegateBuilder = (SAMLObjectBuilder<Delegate>)
+                builderFactory.getBuilder(Delegate.DEFAULT_ELEMENT_NAME);
+        }
+
+        for (DelegateBean delegateBean : delegates) {
+            Delegate delegate = delegateBuilder.buildObject();
+            delegate.setConfirmationMethod(delegateBean.getConfirmationMethod());
+            delegate.setDelegationInstant(delegateBean.getDelegationInstant());
+
+            if (delegateBean.getNameIDBean() == null) {
+                throw new IllegalStateException(
+                   "The value of NameIDBean in DelegateBean may not be null"
+                );
+            }
+            NameID nameID = createNameID(delegateBean.getNameIDBean());
+            delegate.setNameID(nameID);
+            delegationRestriction.getDelegates().add(delegate);
+        }
+
+        return delegationRestriction;
+    }
+
+    /**
+     * Create a OneTimeUse object
+     *
+     * @return a OneTimeUse object
+     */
+    @SuppressWarnings("unchecked")
+    public static OneTimeUse createOneTimeUse() {
+        if (oneTimeUseBuilder == null) {
+            oneTimeUseBuilder = (SAMLObjectBuilder<OneTimeUse>)
+                builderFactory.getBuilder(OneTimeUse.DEFAULT_ELEMENT_NAME);
+        }
+
+        return oneTimeUseBuilder.buildObject();
+    }
+
+    /**
+     * Create a ProxyRestriction object
+     *
+     * @return a ProxyRestriction object
+     */
+    @SuppressWarnings("unchecked")
+    public static ProxyRestriction createProxyRestriction(ProxyRestrictionBean proxyRestrictionBean) {
+        if (proxyRestrictionBuilder == null) {
+            proxyRestrictionBuilder = (SAMLObjectBuilder<ProxyRestriction>)
+                builderFactory.getBuilder(ProxyRestriction.DEFAULT_ELEMENT_NAME);
+        }
+
+        ProxyRestriction proxyRestriction = proxyRestrictionBuilder.buildObject();
+        if (proxyRestrictionBean.getCount() > 0) {
+            proxyRestriction.setProxyCount(proxyRestrictionBean.getCount());
+        }
+
+        if (!proxyRestrictionBean.getAudienceURIs().isEmpty()) {
+            if (audienceBuilder == null) {
+                audienceBuilder = (SAMLObjectBuilder<Audience>)
+                    builderFactory.getBuilder(Audience.DEFAULT_ELEMENT_NAME);
+            }
+            for (String audienceURI : proxyRestrictionBean.getAudienceURIs()) {
+                Audience audience = audienceBuilder.buildObject();
+                audience.setURI(audienceURI);
+                proxyRestriction.getAudiences().add(audience);
+            }
+        }
+
+        return proxyRestriction;
+    }
+
+    /**
+     * Create SAML 2 Authentication Statement(s).
+     *
+     * @param authBeans A list of AuthenticationStatementBean instances
+     * @return SAML 2 Authentication Statement(s).
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AuthnStatement> createAuthnStatement(
+        List<AuthenticationStatementBean> authBeans
+    ) {
+        List<AuthnStatement> authnStatements = new ArrayList<>();
+
+        if (authnStatementBuilder == null) {
+            authnStatementBuilder = (SAMLObjectBuilder<AuthnStatement>)
+                builderFactory.getBuilder(AuthnStatement.DEFAULT_ELEMENT_NAME);
+        }
+        if (authnContextBuilder == null) {
+            authnContextBuilder = (SAMLObjectBuilder<AuthnContext>)
+                builderFactory.getBuilder(AuthnContext.DEFAULT_ELEMENT_NAME);
+        }
+        if (authnContextClassRefBuilder == null) {
+            authnContextClassRefBuilder = (SAMLObjectBuilder<AuthnContextClassRef>)
+                builderFactory.getBuilder(AuthnContextClassRef.DEFAULT_ELEMENT_NAME);
+        }
+        if (subjectLocalityBuilder == null) {
+            subjectLocalityBuilder = (SAMLObjectBuilder<SubjectLocality>)
+            builderFactory.getBuilder(SubjectLocality.DEFAULT_ELEMENT_NAME);
+        }
+
+        if (authBeans != null && !authBeans.isEmpty()) {
+            for (AuthenticationStatementBean statementBean : authBeans) {
+                AuthnStatement authnStatement = authnStatementBuilder.buildObject();
+                Instant authInstant = statementBean.getAuthenticationInstant();
+                if (authInstant == null) {
+                    authInstant = Instant.now();
+                }
+                authnStatement.setAuthnInstant(authInstant);
+
+                Instant sessionNotOnOrAfter = statementBean.getSessionNotOnOrAfter();
+                if (sessionNotOnOrAfter != null) {
+                    authnStatement.setSessionNotOnOrAfter(sessionNotOnOrAfter);
+                }
+
+                if (statementBean.getSessionIndex() != null) {
+                    authnStatement.setSessionIndex(statementBean.getSessionIndex());
+                }
+
+                AuthnContextClassRef authnContextClassRef = authnContextClassRefBuilder.buildObject();
+                authnContextClassRef.setURI(
+                    transformAuthenticationMethod(statementBean.getAuthenticationMethod())
+                );
+                AuthnContext authnContext = authnContextBuilder.buildObject();
+                authnContext.setAuthnContextClassRef(authnContextClassRef);
+                authnStatement.setAuthnContext(authnContext);
+
+                SubjectLocalityBean subjectLocalityBean = statementBean.getSubjectLocality();
+                if (subjectLocalityBean != null) {
+                    SubjectLocality subjectLocality = subjectLocalityBuilder.buildObject();
+                    subjectLocality.setDNSName(subjectLocalityBean.getDnsAddress());
+                    subjectLocality.setAddress(subjectLocalityBean.getIpAddress());
+
+                    authnStatement.setSubjectLocality(subjectLocality);
+                }
+
+                authnStatements.add(authnStatement);
+            }
+        }
+
+        return authnStatements;
+    }
+
+    /**
+     * Transform the user-supplied authentication method value into one of the supported
+     * specification-compliant values.
+     *
+     * @param sourceMethod of type String
+     * @return String
+     */
+    private static String transformAuthenticationMethod(String sourceMethod) {
+        String transformedMethod = "";
+
+        if ("Password".equalsIgnoreCase(sourceMethod)) {
+            transformedMethod = SAML2Constants.AUTH_CONTEXT_CLASS_REF_PASSWORD;
+        } else if (sourceMethod != null && sourceMethod.length() != 0) {
+            return sourceMethod;
+        }
+
+        return transformedMethod;
+    }
+
+    /**
+     * Create a SAML2 Attribute
+     *
+     * @param friendlyName of type String
+     * @param name         of type String
+     * @param nameFormat   of type String
+     * @param values       of type ArrayList
+     * @return a SAML2 Attribute
+     */
+    public static Attribute createAttribute(
+        String friendlyName, String name, String nameFormat, List<Object> values
+    ) {
+        if (stringBuilder == null) {
+            stringBuilder = (XSStringBuilder)builderFactory.getBuilder(XSString.TYPE_NAME);
+        }
+        Attribute attribute = createAttribute(friendlyName, name, nameFormat);
+
+        for (Object value : values) {
+            if (value instanceof String) {
+                XSString attributeValue =
+                    stringBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
+                attributeValue.setValue((String)value);
+                attribute.getAttributeValues().add(attributeValue);
+            } else if (value instanceof XMLObject) {
+                attribute.getAttributeValues().add((XMLObject)value);
+            }
+        }
+
+        return attribute;
+    }
+
+    /**
+     * Create a Subject.
+     *
+     * @param subjectBean of type SubjectBean
+     * @return a Subject
+     */
+    @SuppressWarnings("unchecked")
+    public static Subject createSaml2Subject(SubjectBean subjectBean)
+        throws org.opensaml.security.SecurityException, WSSecurityException {
+        if (subjectBuilder == null) {
+            subjectBuilder = (SAMLObjectBuilder<Subject>)
+                builderFactory.getBuilder(Subject.DEFAULT_ELEMENT_NAME);
+        }
+        Subject subject = subjectBuilder.buildObject();
+
+        NameID nameID = SAML2ComponentBuilder.createNameID(subjectBean);
+        subject.setNameID(nameID);
+
+        SubjectConfirmationData subjectConfData = null;
+        if (subjectBean.getKeyInfo() != null || subjectBean.getSubjectConfirmationData() != null) {
+            subjectConfData =
+                SAML2ComponentBuilder.createSubjectConfirmationData(
+                    subjectBean.getSubjectConfirmationData(),
+                    subjectBean.getKeyInfo()
+                );
+        }
+
+        NameID subjectConfNameId = null;
+        if (subjectBean.getSubjectConfirmationNameID() != null) {
+            subjectConfNameId = SAML2ComponentBuilder.createNameID(subjectBean.getSubjectConfirmationNameID());
+        }
+
+        String confirmationMethodStr = subjectBean.getSubjectConfirmationMethod();
+        if (confirmationMethodStr == null) {
+            confirmationMethodStr = SAML2Constants.CONF_SENDER_VOUCHES;
+        }
+        SubjectConfirmation subjectConfirmation =
+            SAML2ComponentBuilder.createSubjectConfirmation(
+                confirmationMethodStr, subjectConfData, subjectConfNameId
+            );
+
+        subject.getSubjectConfirmations().add(subjectConfirmation);
+        return subject;
+    }
+
+    /**
+     * Create a SubjectConfirmationData object
+     *
+     * @param subjectConfirmationDataBean of type SubjectConfirmationDataBean
+     * @param keyInfoBean of type KeyInfoBean
+     * @return a SubjectConfirmationData object
+     */
+    @SuppressWarnings("unchecked")
+    public static SubjectConfirmationData createSubjectConfirmationData(
+        SubjectConfirmationDataBean subjectConfirmationDataBean,
+        KeyInfoBean keyInfoBean
+    ) throws org.opensaml.security.SecurityException, WSSecurityException {
+        SubjectConfirmationData subjectConfirmationData = null;
+        KeyInfo keyInfo = null;
+        if (keyInfoBean == null) {
+            if (subjectConfirmationDataBuilder == null) {
+                subjectConfirmationDataBuilder = (SAMLObjectBuilder<SubjectConfirmationData>)
+                    builderFactory.getBuilder(SubjectConfirmationData.DEFAULT_ELEMENT_NAME);
+            }
+            subjectConfirmationData = subjectConfirmationDataBuilder.buildObject();
+        } else {
+            if (keyInfoConfirmationDataBuilder == null) {
+                keyInfoConfirmationDataBuilder = (SAMLObjectBuilder<KeyInfoConfirmationDataType>)
+                    builderFactory.getBuilder(KeyInfoConfirmationDataType.TYPE_NAME);
+            }
+            subjectConfirmationData = keyInfoConfirmationDataBuilder.buildObject();
+            keyInfo = SAML1ComponentBuilder.createKeyInfo(keyInfoBean);
+            ((KeyInfoConfirmationDataType)subjectConfirmationData).getKeyInfos().add(keyInfo);
+        }
+
+        if (subjectConfirmationDataBean != null) {
+            if (subjectConfirmationDataBean.getInResponseTo() != null) {
+                subjectConfirmationData.setInResponseTo(subjectConfirmationDataBean.getInResponseTo());
+            }
+            if (subjectConfirmationDataBean.getRecipient() != null) {
+                subjectConfirmationData.setRecipient(subjectConfirmationDataBean.getRecipient());
+            }
+            if (subjectConfirmationDataBean.getAddress() != null) {
+                subjectConfirmationData.setAddress(subjectConfirmationDataBean.getAddress());
+            }
+            if (subjectConfirmationDataBean.getNotAfter() != null) {
+                subjectConfirmationData.setNotOnOrAfter(subjectConfirmationDataBean.getNotAfter());
+            }
+            if (subjectConfirmationDataBean.getNotBefore() != null) {
+                subjectConfirmationData.setNotBefore(subjectConfirmationDataBean.getNotBefore());
+            }
+            if (subjectConfirmationDataBean.getAny() != null) {
+                List<XMLObject> unknownObjects = subjectConfirmationData.getUnknownXMLObjects();
+                for (Object obj : subjectConfirmationDataBean.getAny()) {
+                    if (obj == null) {
+                        LOG.warn("Ignore <null> object in SubjectConfirmationData.any");
+                    } else if (obj instanceof XMLObject) {
+                        unknownObjects.add((XMLObject) obj);
+                    } else if (obj instanceof AttributeStatementBean) {
+                        unknownObjects.addAll(createAttributeStatement(Collections.singletonList((AttributeStatementBean) obj)));
+                    } else {
+                        LOG.warn("Ignore object of the unsupported type {} in SubjectConfirmationData.any", obj.getClass());
+                    }
+                }
+            }
+        }
+
+        return subjectConfirmationData;
+    }
+
+    /**
+     * Create a SubjectConfirmation object
+     * One of the following subject confirmation methods MUST be used:
+     *   urn:oasis:names:tc:SAML:2.0:cm:holder-of-key
+     *   urn:oasis:names:tc:SAML:2.0:cm:sender-vouches
+     *   urn:oasis:names:tc:SAML:2.0:cm:bearer
+     *
+     * @param method of type String
+     * @param subjectConfirmationData of type SubjectConfirmationData
+     * @return a SubjectConfirmation object
+     */
+    @SuppressWarnings("unchecked")
+    public static SubjectConfirmation createSubjectConfirmation(
+        String method,
+        SubjectConfirmationData subjectConfirmationData,
+        NameID subjectConfirmationNameId
+    ) {
+        if (subjectConfirmationBuilder == null) {
+            subjectConfirmationBuilder = (SAMLObjectBuilder<SubjectConfirmation>)
+                builderFactory.getBuilder(SubjectConfirmation.DEFAULT_ELEMENT_NAME);
+        }
+
+        SubjectConfirmation subjectConfirmation = subjectConfirmationBuilder.buildObject();
+        subjectConfirmation.setMethod(method);
+        subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
+        subjectConfirmation.setNameID(subjectConfirmationNameId);
+        return subjectConfirmation;
+    }
+
+    /**
+     * Create a NameID object
+     * One of the following formats MUST be used:
+     *   urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
+     *   urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress
+     *   urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName
+     *   urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName
+     *   urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos
+     *   urn:oasis:names:tc:SAML:2.0:nameid-format:entity
+     *   urn:oasis:names:tc:SAML:2.0:nameid-format:persistent
+     *   urn:oasis:names:tc:SAML:2.0:nameid-format:transient
+     *
+     * @param subject A SubjectBean instance
+     * @return NameID
+     */
+    public static NameID createNameID(SubjectBean subject) {
+        NameIDBean nameIDBean = new NameIDBean();
+        nameIDBean.setNameIDFormat(subject.getSubjectNameIDFormat());
+        nameIDBean.setNameQualifier(subject.getSubjectNameQualifier());
+        nameIDBean.setSPNameQualifier(subject.getSubjectNameSPNameQualifier());
+        nameIDBean.setSPProvidedID(subject.getSubjectNameSPProvidedID());
+        nameIDBean.setNameValue(subject.getSubjectName());
+        return createNameID(nameIDBean);
+    }
+
+    @SuppressWarnings("unchecked")
+    public static NameID createNameID(NameIDBean nameIDBean) {
+        if (nameIdBuilder == null) {
+            nameIdBuilder = (SAMLObjectBuilder<NameID>)
+                builderFactory.getBuilder(NameID.DEFAULT_ELEMENT_NAME);
+        }
+        NameID nameID = nameIdBuilder.buildObject();
+        nameID.setNameQualifier(nameIDBean.getNameQualifier());
+        nameID.setFormat(nameIDBean.getNameIDFormat());
+        nameID.setValue(nameIDBean.getNameValue());
+        nameID.setSPNameQualifier(nameIDBean.getSPNameQualifier());
+        nameID.setSPProvidedID(nameIDBean.getSPProvidedID());
+        return nameID;
+    }
+
+    /**
+     * Create SAML2 Attribute Statement(s)
+     *
+     * @param attributeData A list of AttributeStatementBean instances
+     * @return SAML2 Attribute Statement(s)
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AttributeStatement> createAttributeStatement(
+        List<AttributeStatementBean> attributeData
+    ) {
+        List<AttributeStatement> attributeStatements = new ArrayList<>();
+        if (attributeStatementBuilder == null) {
+            attributeStatementBuilder = (SAMLObjectBuilder<AttributeStatement>)
+            builderFactory.getBuilder(AttributeStatement.DEFAULT_ELEMENT_NAME);
+        }
+
+        if (attributeData != null && !attributeData.isEmpty()) {
+            for (AttributeStatementBean statementBean : attributeData) {
+                AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
+                for (AttributeBean values : statementBean.getSamlAttributes()) {
+                    List<Object> attributeValues = values.getAttributeValues();
+                    Attribute samlAttribute =
+                        createAttribute(
+                            values.getSimpleName(),
+                            values.getQualifiedName(),
+                            values.getNameFormat(),
+                            attributeValues
+                        );
+                    attributeStatement.getAttributes().add(samlAttribute);
+                }
+                // Add the completed attribute statementBean to the collection
+                attributeStatements.add(attributeStatement);
+            }
+        }
+
+        return attributeStatements;
+    }
+
+    /**
+     * Create an Attribute object.
+     *
+     * @param friendlyName of type String
+     * @param name of type String
+     * @param nameFormat of type String
+     * @return an Attribute object
+     */
+    @SuppressWarnings("unchecked")
+    public static Attribute createAttribute(String friendlyName, String name, String nameFormat) {
+        if (attributeBuilder == null) {
+            attributeBuilder = (SAMLObjectBuilder<Attribute>)
+                builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
+        }
+
+        Attribute attribute = attributeBuilder.buildObject();
+        attribute.setFriendlyName(friendlyName);
+        if (nameFormat == null) {
+            attribute.setNameFormat(SAML2Constants.ATTRNAME_FORMAT_URI);
+        } else {
+            attribute.setNameFormat(nameFormat);
+        }
+        attribute.setName(name);
+        return attribute;
+    }
+
+    /**
+     * Create SAML2 AuthorizationDecisionStatement(s)
+     *
+     * @param decisionData A list of AuthDecisionStatementBean instances
+     * @return SAML2 AuthorizationDecisionStatement(s)
+     */
+    @SuppressWarnings("unchecked")
+    public static List<AuthzDecisionStatement> createAuthorizationDecisionStatement(
+        List<AuthDecisionStatementBean> decisionData
+    ) {
+        List<AuthzDecisionStatement> authDecisionStatements = new ArrayList<>();
+        if (authorizationDecisionStatementBuilder == null) {
+            authorizationDecisionStatementBuilder =
+                (SAMLObjectBuilder<AuthzDecisionStatement>)
+                    builderFactory.getBuilder(AuthzDecisionStatement.DEFAULT_ELEMENT_NAME);
+        }
+
+        if (decisionData != null && !decisionData.isEmpty()) {
+            for (AuthDecisionStatementBean decisionStatementBean : decisionData) {
+                AuthzDecisionStatement authDecision =
+                    authorizationDecisionStatementBuilder.buildObject();
+                authDecision.setResource(decisionStatementBean.getResource());
+                authDecision.setDecision(
+                    transformDecisionType(decisionStatementBean.getDecision())
+                );
+
+                for (ActionBean actionBean : decisionStatementBean.getActions()) {
+                    Action actionElement = createSamlAction(actionBean);
+                    authDecision.getActions().add(actionElement);
+                }
+
+                if (decisionStatementBean.getEvidence() instanceof Evidence) {
+                    authDecision.setEvidence((Evidence)decisionStatementBean.getEvidence());
+                }
+
+                authDecisionStatements.add(authDecision);
+            }
+        }
+
+        return authDecisionStatements;
+    }
+
+
+    /**
+     * Create an Action object
+     *
+     * @param actionBean An ActionBean instance
+     * @return an Action object
+     */
+    @SuppressWarnings("unchecked")
+    public static Action createSamlAction(ActionBean actionBean) {
+        if (actionElementBuilder == null) {
+            actionElementBuilder = (SAMLObjectBuilder<Action>)
+                builderFactory.getBuilder(Action.DEFAULT_ELEMENT_NAME);
+        }
+        Action actionElement = actionElementBuilder.buildObject();
+        actionElement.setNamespace(actionBean.getActionNamespace());
+        if (actionBean.getActionNamespace() == null) {
+            actionElement.setNamespace("urn:oasis:names:tc:SAML:1.0:action:rwedc-negation");
+        }
+        actionElement.setValue(actionBean.getContents());
+
+        return actionElement;
+    }
+
+    /**
+     * Create a DecisionTypeEnumeration object
+     *
+     * @param decision of type Decision
+     * @return a DecisionTypeEnumeration object
+     */
+    private static DecisionTypeEnumeration transformDecisionType(
+        AuthDecisionStatementBean.Decision decision
+    ) {
+        DecisionTypeEnumeration decisionTypeEnum = DecisionTypeEnumeration.DENY;
+        if (decision.equals(AuthDecisionStatementBean.Decision.PERMIT)) {
+            decisionTypeEnum = DecisionTypeEnumeration.PERMIT;
+        } else if (decision.equals(AuthDecisionStatementBean.Decision.INDETERMINATE)) {
+            decisionTypeEnum = DecisionTypeEnumeration.INDETERMINATE;
+        }
+
+        return decisionTypeEnum;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2Constants.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2Constants.java
new file mode 100644
index 000000000..5426f113a
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/builder/SAML2Constants.java
@@ -0,0 +1,164 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml.builder;
+
+
+/**
+ * Class SAML2Constants provides static constant definitions associated with
+ * the SAML v2.x specification.
+ */
+public final class SAML2Constants {
+    //
+    // NAME ID FORMAT
+    //
+
+    public static final String NAMEID_FORMAT_UNSPECIFIED =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";
+
+    public static final String NAMEID_FORMAT_EMAIL_ADDRESS =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress";
+
+    public static final String NAMEID_FORMAT_X509_SUBJECT_NAME =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:X509SubjectName";
+
+    public static final String NAMEID_FORMAT_WINDOWS_DQN =
+        "urn:oasis:names:tc:SAML:1.1:nameid-format:WindowsDomainQualifiedName";
+
+    public static final String NAMEID_FORMAT_KERBEROS =
+        "urn:oasis:names:tc:SAML:2.0:nameid-format:kerberos";
+
+    public static final String NAMEID_FORMAT_ENTITY =
+        "urn:oasis:names:tc:SAML:2.0:nameid-format:entity";
+
+    public static final String NAMEID_FORMAT_PERSISTENT =
+        "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
+
+    public static final String NAMEID_FORMAT_TRANSIENT =
+        "urn:oasis:names:tc:SAML:2.0:nameid-format:transient";
+
+    //
+    // SUBJECT CONFIRMATION
+    //
+
+    public static final String CONF_BEARER =
+        "urn:oasis:names:tc:SAML:2.0:cm:bearer";
+
+    public static final String CONF_HOLDER_KEY =
+        "urn:oasis:names:tc:SAML:2.0:cm:holder-of-key";
+
+    public static final String CONF_SENDER_VOUCHES =
+        "urn:oasis:names:tc:SAML:2.0:cm:sender-vouches";
+
+    //
+    // AUTH CONTEXT CLASS REF
+    //
+
+    public static final String AUTH_CONTEXT_CLASS_REF_INTERNET_PROTOCOL =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocol";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_INTERNET_PROTOCOL_PASSWORD =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:InternetProtocolPassword";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_KERBEROS =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:Kerberos";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_MOBILE_ONE_FACTOR_UNREGISTERED =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileOneFactorUnregistered";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_MOBILE_TWO_FACTOR_UNREGISTERED =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorUnregistered";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_MOBILE_ONE_FACTOR_CONTRACT =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileOneFactorContract";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_MOBILE_TWO_FACTOR_CONTRACT =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:MobileTwoFactorContract";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_PASSWORD =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:Password";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_PASSWORD_PROTECTED_TRANSPORT =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_PREVIOUS_SESSION =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:PreviousSession";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_X509 =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:X509";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_PGP =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:PGP";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_SPKI =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:SPKI";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_XMLDSIG =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:XMLDSig";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_SMARTCARD =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:Smartcard";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_SMARTCARD_PKI =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:SmartcardPKI";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_SOFTWARE_PKI =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:SoftwarePKI";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_TELEPHONY =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:Telephony";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_NOMAD_TELEPHONY =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:NomadTelephony";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_PERSONAL_TELEPHONY =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:PersonalTelephony";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_AUTHENTICATED_TELEPHONY =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:AuthenticatedTelephony";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_SECURED_REMOTE_PASSWORD =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:SecureRemotePassword";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_TLS_CLIENT =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:TLSClient";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_TIME_SYNC_TOKEN =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:TimeSyncToken";
+
+    public static final String AUTH_CONTEXT_CLASS_REF_UNSPECIFIED =
+        "urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified";
+
+    //
+    // ATTRIBUTE NAME FORMAT
+    //
+
+    public static final String ATTRNAME_FORMAT_UNSPECIFIED =
+        "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified";
+
+    public static final String ATTRNAME_FORMAT_URI =
+        "urn:oasis:names:tc:SAML:2.0:attrname-format:uri";
+
+    public static final String ATTRNAME_FORMAT_BASIC =
+        "urn:oasis:names:tc:SAML:2.0:attrname-format:basic";
+
+    private SAML2Constants() {
+        // Complete
+    }
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipal.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipal.java
new file mode 100644
index 000000000..e83601960
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipal.java
@@ -0,0 +1,32 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wss4j.common.principal;
+
+import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+
+import java.security.Principal;
+
+public interface SAMLTokenPrincipal extends Principal {
+
+    SamlAssertionWrapper getToken();
+
+    String getName();
+
+    String getId();
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipalImpl.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipalImpl.java
new file mode 100644
index 000000000..85e9e802e
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/principal/SAMLTokenPrincipalImpl.java
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.principal;
+
+import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+
+import java.io.Serializable;
+
+/**
+ * A principal that represents a SAML Token. It parses the Subject and returns the Subject
+ * name value as the Principal name.
+ */
+public class SAMLTokenPrincipalImpl implements Serializable, SAMLTokenPrincipal {
+    private static final long serialVersionUID = 1L;
+
+    private String name;
+    private SamlAssertionWrapper samlAssertion;
+
+    public SAMLTokenPrincipalImpl(SamlAssertionWrapper samlAssertion) {
+        this.samlAssertion = samlAssertion;
+        this.name = samlAssertion.getSubjectName();
+    }
+
+    @Override
+    public SamlAssertionWrapper getToken() {
+        return samlAssertion;
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public String getId() {
+        if (samlAssertion != null) {
+            return samlAssertion.getId();
+        }
+        return null;
+    }
+
+}
diff --git a/ws-security-saml/src/main/java/org/apache/wss4j/saml/processor/SAMLTokenProcessor.java b/ws-security-saml/src/main/java/org/apache/wss4j/saml/processor/SAMLTokenProcessor.java
new file mode 100644
index 000000000..491c655d9
--- /dev/null
+++ b/ws-security-saml/src/main/java/org/apache/wss4j/saml/processor/SAMLTokenProcessor.java
@@ -0,0 +1,285 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.dom.processor;
+
+import java.security.NoSuchProviderException;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.crypto.MarshalException;
+import javax.xml.crypto.dsig.Reference;
+import javax.xml.crypto.dsig.Transform;
+import javax.xml.crypto.dsig.XMLSignature;
+import javax.xml.crypto.dsig.XMLSignatureFactory;
+import javax.xml.crypto.dsig.XMLValidateContext;
+import javax.xml.crypto.dsig.dom.DOMValidateContext;
+import javax.xml.namespace.QName;
+
+import org.apache.wss4j.common.crypto.AlgorithmSuite;
+import org.apache.wss4j.common.crypto.AlgorithmSuiteValidator;
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.common.principal.SAMLTokenPrincipalImpl;
+import org.apache.wss4j.common.saml.SAMLKeyInfo;
+import org.apache.wss4j.common.saml.SAMLUtil;
+import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+import org.apache.wss4j.common.util.DOM2Writer;
+import org.apache.wss4j.dom.WSConstants;
+import org.apache.wss4j.dom.WSDataRef;
+import org.apache.wss4j.dom.engine.WSSecurityEngineResult;
+import org.apache.wss4j.dom.handler.RequestData;
+import org.apache.wss4j.dom.saml.WSSSAMLKeyInfoProcessor;
+import org.apache.wss4j.dom.util.EncryptionUtils;
+import org.apache.wss4j.dom.validate.Credential;
+import org.apache.wss4j.dom.validate.Validator;
+import org.opensaml.xmlsec.signature.KeyInfo;
+import org.opensaml.xmlsec.signature.Signature;
+import org.w3c.dom.Element;
+
+public class SAMLTokenProcessor implements Processor {
+    private static final org.slf4j.Logger LOG =
+        org.slf4j.LoggerFactory.getLogger(SAMLTokenProcessor.class);
+    private XMLSignatureFactory signatureFactory;
+
+    public SAMLTokenProcessor() {
+        init(null);
+    }
+
+    public SAMLTokenProcessor(Provider provider) {
+        init(provider);
+    }
+
+    private void init(Provider provider) {
+        if (provider == null) {
+            // Try to install the Santuario Provider - fall back to the JDK provider if this does
+            // not work
+            try {
+                signatureFactory = XMLSignatureFactory.getInstance("DOM", "ApacheXMLDSig");
+            } catch (NoSuchProviderException ex) {
+                signatureFactory = XMLSignatureFactory.getInstance("DOM");
+            }
+        } else {
+            signatureFactory = XMLSignatureFactory.getInstance("DOM", provider);
+        }
+    }
+
+    public List<WSSecurityEngineResult> handleToken(
+        Element elem,
+        RequestData data
+    ) throws WSSecurityException {
+        LOG.debug("Found SAML Assertion element");
+
+        Validator validator =
+            data.getValidator(new QName(elem.getNamespaceURI(), elem.getLocalName()));
+
+        SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(elem);
+        XMLSignature xmlSignature = verifySignatureKeysAndAlgorithms(samlAssertion, data);
+        List<WSDataRef> dataRefs = createDataRefs(elem, samlAssertion, xmlSignature);
+
+        Credential credential = handleSAMLToken(samlAssertion, data, validator);
+        samlAssertion = credential.getSamlAssertion();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("SAML Assertion issuer " + samlAssertion.getIssuerString());
+            LOG.debug(DOM2Writer.nodeToString(elem));
+        }
+
+        // See if the token has been previously processed
+        String id = samlAssertion.getId();
+        Element foundElement = data.getWsDocInfo().getTokenElement(id);
+        if (elem.equals(foundElement)) {
+            WSSecurityEngineResult result = data.getWsDocInfo().getResult(id);
+            return java.util.Collections.singletonList(result);
+        } else if (foundElement != null) {
+            throw new WSSecurityException(
+                WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN, "duplicateError"
+            );
+        }
+
+        data.getWsDocInfo().addTokenElement(elem);
+        WSSecurityEngineResult result = null;
+        if (samlAssertion.isSigned()) {
+            result = new WSSecurityEngineResult(WSConstants.ST_SIGNED, samlAssertion);
+            result.put(WSSecurityEngineResult.TAG_DATA_REF_URIS, dataRefs);
+            result.put(WSSecurityEngineResult.TAG_SIGNATURE_VALUE, samlAssertion.getSignatureValue());
+        } else {
+            result = new WSSecurityEngineResult(WSConstants.ST_UNSIGNED, samlAssertion);
+        }
+
+        if (id.length() != 0) {
+            result.put(WSSecurityEngineResult.TAG_ID, id);
+        }
+
+        if (validator != null) {
+            result.put(WSSecurityEngineResult.TAG_VALIDATED_TOKEN, Boolean.TRUE);
+            if (credential.getTransformedToken() != null) {
+                result.put(
+                    WSSecurityEngineResult.TAG_TRANSFORMED_TOKEN, credential.getTransformedToken()
+                );
+                if (credential.getPrincipal() != null) {
+                    result.put(WSSecurityEngineResult.TAG_PRINCIPAL, credential.getPrincipal());
+                } else {
+                    SAMLTokenPrincipalImpl samlPrincipal =
+                        new SAMLTokenPrincipalImpl(credential.getTransformedToken());
+                    result.put(WSSecurityEngineResult.TAG_PRINCIPAL, samlPrincipal);
+                }
+            } else if (credential.getPrincipal() != null) {
+                result.put(WSSecurityEngineResult.TAG_PRINCIPAL, credential.getPrincipal());
+            } else {
+                result.put(WSSecurityEngineResult.TAG_PRINCIPAL, new SAMLTokenPrincipalImpl(samlAssertion));
+            }
+            result.put(WSSecurityEngineResult.TAG_SUBJECT, credential.getSubject());
+        }
+        data.getWsDocInfo().addResult(result);
+        return java.util.Collections.singletonList(result);
+    }
+
+    public Credential handleSAMLToken(
+        SamlAssertionWrapper samlAssertion,
+        RequestData data,
+        Validator validator
+    ) throws WSSecurityException {
+        // Parse the subject if it exists
+        samlAssertion.parseSubject(
+            new WSSSAMLKeyInfoProcessor(data), data.getSigVerCrypto()
+        );
+
+        // Now delegate the rest of the verification to the Validator
+        Credential credential = new Credential();
+        credential.setSamlAssertion(samlAssertion);
+        if (validator != null) {
+            return validator.validate(credential, data);
+        }
+        return credential;
+    }
+
+    private XMLSignature verifySignatureKeysAndAlgorithms(
+        SamlAssertionWrapper samlAssertion,
+        RequestData data
+    ) throws WSSecurityException {
+        if (samlAssertion.isSigned()) {
+            Signature sig = samlAssertion.getSignature();
+            KeyInfo keyInfo = sig.getKeyInfo();
+            if (keyInfo == null) {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"}
+                );
+            }
+            SAMLKeyInfo samlKeyInfo =
+                SAMLUtil.getCredentialFromKeyInfo(
+                    keyInfo.getDOM(), new WSSSAMLKeyInfoProcessor(data), data.getSigVerCrypto()
+                );
+
+            PublicKey key = null;
+            if (samlKeyInfo.getCerts() != null && samlKeyInfo.getCerts()[0] != null) {
+                key = samlKeyInfo.getCerts()[0].getPublicKey();
+            } else if (samlKeyInfo.getPublicKey() != null) {
+                key = samlKeyInfo.getPublicKey();
+            } else {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"});
+            }
+
+            // Not checking signature here, just marshalling into an XMLSignature
+            // structure for testing the transform/digest algorithms etc.
+            XMLValidateContext context = new DOMValidateContext(key, sig.getDOM());
+            context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
+            context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);
+            if (data.getSignatureProvider() != null) {
+                context.setProperty("org.jcp.xml.dsig.internal.dom.SignatureProvider", data.getSignatureProvider());
+            }
+
+            XMLSignature xmlSignature;
+            try {
+                xmlSignature = signatureFactory.unmarshalXMLSignature(context);
+            } catch (MarshalException ex) {
+                throw new WSSecurityException(
+                    WSSecurityException.ErrorCode.FAILED_CHECK, ex, "invalidSAMLsecurity",
+                    new Object[] {"cannot get certificate or key"}
+                );
+            }
+
+            // Check for compliance against the defined AlgorithmSuite
+            AlgorithmSuite algorithmSuite = data.getSamlAlgorithmSuite();
+            if (algorithmSuite != null) {
+                AlgorithmSuiteValidator algorithmSuiteValidator = new
+                    AlgorithmSuiteValidator(algorithmSuite);
+
+                algorithmSuiteValidator.checkSignatureAlgorithms(xmlSignature);
+
+                if (samlKeyInfo.getCerts() != null && samlKeyInfo.getCerts().length > 0) {
+                    algorithmSuiteValidator.checkAsymmetricKeyLength(samlKeyInfo.getCerts());
+                } else {
+                    algorithmSuiteValidator.checkAsymmetricKeyLength(key);
+                }
+            }
+
+            samlAssertion.verifySignature(samlKeyInfo);
+
+            return xmlSignature;
+        }
+
+        return null;
+    }
+
+    private List<WSDataRef> createDataRefs(
+        Element token, SamlAssertionWrapper samlAssertion, XMLSignature xmlSignature
+    ) {
+        if (xmlSignature == null) {
+            return Collections.emptyList();
+        }
+
+        List<WSDataRef> protectedRefs = new ArrayList<>();
+        String signatureMethod =
+            xmlSignature.getSignedInfo().getSignatureMethod().getAlgorithm();
+
+        for (Object refObject : xmlSignature.getSignedInfo().getReferences()) {
+            Reference reference = (Reference)refObject;
+
+            if (reference.getURI() == null || reference.getURI().length() == 0
+                || reference.getURI().equals(samlAssertion.getId())
+                || reference.getURI().equals("#" + samlAssertion.getId())) {
+                WSDataRef ref = new WSDataRef();
+                ref.setWsuId(reference.getURI());
+                ref.setProtectedElement(token);
+                ref.setAlgorithm(signatureMethod);
+                ref.setDigestAlgorithm(reference.getDigestMethod().getAlgorithm());
+                ref.setDigestValue(reference.getDigestValue());
+
+                // Set the Transform algorithms as well
+                @SuppressWarnings("unchecked")
+                List<Transform> transforms = reference.getTransforms();
+                List<String> transformAlgorithms = new ArrayList<>(transforms.size());
+                for (Transform transform : transforms) {
+                    transformAlgorithms.add(transform.getAlgorithm());
+                }
+                ref.setTransformAlgorithms(transformAlgorithms);
+
+                ref.setXpath(EncryptionUtils.getXPath(token));
+                protectedRefs.add(ref);
+            }
+        }
+
+        return protectedRefs;
+    }
+}
diff --git a/ws-security-saml/src/main/resources/saml2-xacml2-profile.xml b/ws-security-saml/src/main/resources/saml2-xacml2-profile.xml
new file mode 100644
index 000000000..95ff3c66b
--- /dev/null
+++ b/ws-security-saml/src/main/resources/saml2-xacml2-profile.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<XMLTooling xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xacml-samlp="urn:oasis:xacml:2.0:saml:protocol:schema:os" xmlns:xacml-saml="urn:oasis:xacml:2.0:saml:assertion:schema:os" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns="http://www.opensaml.org/xmltooling-config">
+
+    <!-- XACML 2.0 for SAML 2 Profile Object Providers -->
+	<ObjectProviders>
+    
+		<!-- ReferencedPoliciesType -->
+        <ObjectProvider qualifiedName="xacml-saml:ReferencedPolicies">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+        <!-- ReferencedPoliciesType -->
+        <ObjectProvider qualifiedName="xacml-saml:ReferencedPoliciesType">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.ReferencedPoliciesTypeUnmarshaller"/>
+        </ObjectProvider>
+	
+         
+       <!-- XACMLAuthzDecisionStatement -->
+        <ObjectProvider qualifiedName="xacml-saml:XACMLAuthzDecisionStatement">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+        <ObjectProvider qualifiedName="xacml-saml:XACMLAuthzDecisionStatementType">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionStatementTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+        <!-- XACMLPolicyStatement -->
+        <ObjectProvider qualifiedName="xacml-saml:XACMLPolicyStatement">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+        <ObjectProvider qualifiedName="xacml-saml:XACMLPolicyStatementType">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyStatementTypeUnmarshaller"/>
+        </ObjectProvider>
+           
+       <!-- XACMLAuthzDecisionQuery provider -->
+        <ObjectProvider qualifiedName="xacml-samlp:XACMLAuthzDecisionQuery">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeUnmarshaller"/>
+        </ObjectProvider>
+     
+        <ObjectProvider qualifiedName="xacml-samlp:XACMLAuthzDecisionQueryType">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLAuthzDecisionQueryTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+        <!-- XACMLPolicyQuery provider -->
+        <ObjectProvider qualifiedName="xacml-samlp:XACMLPolicyQuery">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeUnmarshaller"/>
+        </ObjectProvider>
+     
+        <ObjectProvider qualifiedName="xacml-samlp:XACMLPolicyQueryType">
+            <BuilderClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeImplBuilder"/>
+            <MarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeMarshaller"/>
+            <UnmarshallingClass className="org.opensaml.xacml.profile.saml.impl.XACMLPolicyQueryTypeUnmarshaller"/>
+        </ObjectProvider>
+        
+    </ObjectProviders>
+    
+ </XMLTooling>
diff --git a/ws-security-saml/src/main/resources/wss4j-signature-config.xml b/ws-security-saml/src/main/resources/wss4j-signature-config.xml
new file mode 100644
index 000000000..07ee51572
--- /dev/null
+++ b/ws-security-saml/src/main/resources/wss4j-signature-config.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<XMLTooling xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:ds11="http://www.w3.org/2009/xmldsig11#" xmlns="http://www.opensaml.org/xmltooling-config">
+    
+    <ObjectProviders>
+
+        <!-- X509Certificate -->
+        <ObjectProvider qualifiedName="ds:X509Certificate">
+            <BuilderClass className="org.opensaml.xmlsec.signature.impl.X509CertificateBuilder"/>
+            <MarshallingClass className="org.opensaml.core.xml.schema.impl.XSBase64BinaryMarshaller"/>
+            <UnmarshallingClass className="org.apache.wss4j.common.saml.WSS4JXSBase64BinaryUnmarshaller"/>
+        </ObjectProvider>
+
+    </ObjectProviders>
+    
+</XMLTooling>
diff --git a/ws-security-saml/src/test/java/org/apache/wss4j/common/saml/OpenSAMLUtilTest.java b/ws-security-saml/src/test/java/org/apache/wss4j/common/saml/OpenSAMLUtilTest.java
new file mode 100644
index 000000000..8cc20b258
--- /dev/null
+++ b/ws-security-saml/src/test/java/org/apache/wss4j/common/saml/OpenSAMLUtilTest.java
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.saml;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Some tests for the Merlin Crypto provider
+ */
+public class OpenSAMLUtilTest {
+
+    @Test
+    public void testInitSamlEngine() throws Exception {
+        OpenSAMLUtil.initSamlEngine();
+
+        // https://issues.apache.org/jira/browse/WSS-678 OpenSAML Decrypter initialization failed
+        new org.opensaml.saml.saml2.encryption.Decrypter(null, null, null);
+    }
+
+}
\ No newline at end of file
diff --git a/ws-security-saml/src/test/resources/log4j.properties b/ws-security-saml/src/test/resources/log4j.properties
new file mode 100644
index 000000000..4e79f9c6c
--- /dev/null
+++ b/ws-security-saml/src/test/resources/log4j.properties
@@ -0,0 +1,77 @@
+# Set root category priority to INFO and its only appender to CONSOLE.
+# log4j.rootCategory=FATAL, CONSOLE
+ log4j.rootCategory=DEBUG, LOGFILE
+# log4j.rootCategory=DEBUG, CONSOLE
+
+# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
+# log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
+# log4j.logger.org.apache.axis.i18n.ProjectResourceBundle=INFO
+# log4j.logger.org.apache.wss4j.TIME=DEBUG
+# log4j.logger.org.apache.wss4j.message.EnvelopeIdResolver=DEBUG
+# log4j.logger.org.apache.wss4j.message.WSEncryptBody=INFO
+# log4j.logger.org.apache.wss4j.message.WSSignEnvelope=DEBUG
+# log4j.logger.org.apache.wss4j.processor.ReferenceListProcessor=DEBUG
+# log4j.logger.org.apache.ws.axis.security.WSDoAllSender=DEBUG
+# log4j.logger.org.apache.ws.axis.security.WSDoAllReceiver=DEBUG
+# log4j.logger.org.apache.wss4j.transform.STRTransform=DEBUG
+# log4j.logger.org.apache.wss4j.WSSecurityEngine=DEBUG
+# log4j.logger.org.apache.wss4j.WSSConfig=DEBUG
+# log4j.logger.org.apache.wss4j.message.token.SecurityTokenReference=DEBUG
+# log4j.logger.org.apache.wss4j.common.crypto.Merlin=DEBUG
+# log4j.logger.org.apache.xml.security.encryption.XMLCipher=DEBUG
+# log4j.logger.org.apache.xml.security.algorithms.SignatureAlgorithm=INFO
+# log4j.logger.org.apache.xml.security.signature.XMLSignature=DEBUG
+# log4j.logger.org.apache.xml.security.Init=INFO
+# log4j.logger.org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory=INFO
+# log4j.logger.org.apache.axis.i18n.ProjectResourceBundle=INFO
+# log4j.logger.org.apache.axis.utils.NSStack=INFO
+# log4j.logger.org.apache.axis.encoding.SerializationContextImpl=INFO
+# log4j.logger.org.apache.axis.encoding.DeserializationContextImpl=INFO
+# log4j.logger.org.apache.xml.security.signature.Reference=DEBUG
+# log4j.logger.wssec.TestWSSecurity=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew=DEBUG
+# log4j.logger.wssec.TestWSSecurity1=DEBUG
+# log4j.logger.wssec.TestWSSecurity2=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew2=DEBUG
+# log4j.logger.wssec.TestWSSecurity3=DEBUG
+# log4j.logger.wssec.TestWSSecurity4=DEBUG
+# log4j.logger.wssec.TestWSSecurity5=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew5=DEBUG
+# log4j.logger.wssec.TestWSSecurity6=DEBUG
+# log4j.logger.wssec.TestWSSecurity7=DEBUG
+# log4j.logger.wssec.TestWSSecurity8=DEBUG
+# log4j.logger.wssec.TestWSSecurity9=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew9=DEBUG
+# log4j.logger.wssec.TestWSSecurity10=DEBUG
+# log4j.logger.wssec.TestWSSecurity11=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew11=DEBUG
+# log4j.logger.wssec.TestWSSecurity12=DEBUG
+# log4j.logger.wssec.TestWSSecurity13=DEBUG
+# log4j.logger.wssec.TestWSSecurity14=DEBUG
+# log4j.logger.wssec.TestWSSecurityNew15=DEBUG
+# log4j.logger.wssec.TestWSSecurityST1=DEBUG
+# log4j.logger.wssec.TestWSSecurityNewST1=DEBUG
+# log4j.logger.wssec.TestWSSecurityST2=DEBUG
+# log4j.logger.wssec.TestWSSecurityNewST2=DEBUG
+# log4j.logger.wssec.TestWSSecurityST3=DEBUG
+# log4j.logger.wssec.TestWSSecurityNewST3=DEBUG
+# log4j.logger.wssec.TestWSSecuritySOAP12=DEBUG
+# log4j.logger.wssec.TestWSSecuritySignatureParts=DEBUG
+# log4j.logger.org.apache.wss4j.handler.WSS4JHandler=DEBUG
+# log4j.logger.org.apache.wss4j.handler.WSHandler=DEBUG
+log4j.logger.policy.WSSPolicyTesterAsymm=DEBUG
+log4j.logger.org.apache.wss4j.policy.parser.WSSPolicyProcessor=ERROR
+
+# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Threshold=DEBUG
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
+
+# LOGFILE is set to be a File appender using a PatternLayout.
+log4j.appender.LOGFILE=org.apache.log4j.FileAppender
+log4j.appender.LOGFILE.File=target/wss4j.log
+log4j.appender.LOGFILE.Append=false
+log4j.appender.LOGFILE.Threshold=DEBUG
+log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n