Class SamlAssertionUtils

java.lang.Object
io.jmix.saml.util.SamlAssertionUtils

public class SamlAssertionUtils extends Object
Utility class that provides some methods for working with SAML assertions.
  • Constructor Details

    • SamlAssertionUtils

      public SamlAssertionUtils()
  • Method Details

    • getAssertionAttributes

      public static Map<String,List<Object>> getAssertionAttributes(org.opensaml.saml.saml2.core.Assertion assertion)
      Extracts all attributes from the assertion.
      Parameters:
      assertion - SAML assertion
      Returns:
      map of attribute names to attribute values
    • getSessionIndexes

      public static List<String> getSessionIndexes(org.opensaml.saml.saml2.core.Assertion assertion)
      Extracts session indexes from authentication statements of the assertion. Session indexes identify the user session on the identity provider and must be sent back in the LogoutRequest during single logout.
      Parameters:
      assertion - SAML assertion
      Returns:
      list of session indexes
    • getUsername

      public static @Nullable String getUsername(org.opensaml.saml.saml2.core.Assertion assertion)
      Returns username from the assertion. The username is taken from the plain NameID of the assertion subject.
      Parameters:
      assertion - SAML assertion
      Returns:
      username, or null if the assertion contains no subject, no plain NameID (e.g. the identity provider releases an EncryptedID), or the NameID has no value
    • getNameId

      public static @Nullable org.opensaml.saml.saml2.core.NameID getNameId(org.opensaml.saml.saml2.core.Assertion assertion)
      Returns the plain NameID of the assertion subject.
      Parameters:
      assertion - SAML assertion
      Returns:
      NameID, or null if the assertion contains no subject or no plain NameID
    • getFirstAttributeValue

      public static @Nullable String getFirstAttributeValue(org.opensaml.saml.saml2.core.Assertion assertion, String attributeName)
      Returns the first value of the given assertion attribute.
      Parameters:
      assertion - SAML assertion
      attributeName - name of the assertion attribute
      Returns:
      first attribute value converted to string, or null if the attribute is absent or has no values
    • getXmlObjectValue

      protected static @Nullable Object getXmlObjectValue(org.opensaml.core.xml.XMLObject xmlObject)