def get_sp_metadata(self):
    '\n        Gets the SP metadata. The XML representation.\n        :returns: SP metadata (xml)\n        :rtype: string\n        '
    metadata = OneLogin_Saml2_Metadata.builder(self.__sp, self.__security['authnRequestsSigned'], self.__security['wantAssertionsSigned'], self.__security['metadataValidUntil'], self.__security['metadataCacheDuration'], self.get_contacts(), self.get_organization())
    add_encryption = (self.__security['wantNameIdEncrypted'] or self.__security['wantAssertionsEncrypted'])
    cert_new = self.get_sp_cert_new()
    metadata = OneLogin_Saml2_Metadata.add_x509_key_descriptors(metadata, cert_new, add_encryption)
    cert = self.get_sp_cert()
    metadata = OneLogin_Saml2_Metadata.add_x509_key_descriptors(metadata, cert, add_encryption)
    if (('signMetadata' in self.__security) and (self.__security['signMetadata'] is not False)):
        if (self.__security['signMetadata'] is True):
            if (not cert):
                raise OneLogin_Saml2_Error('Cannot sign metadata: missing SP public key certificate.', OneLogin_Saml2_Error.PUBLIC_CERT_FILE_NOT_FOUND)
            cert_metadata = cert
            key_metadata = self.get_sp_key()
            if (not key_metadata):
                raise OneLogin_Saml2_Error('Cannot sign metadata: missing SP private key.', OneLogin_Saml2_Error.PRIVATE_KEY_FILE_NOT_FOUND)
        else:
            if (('keyFileName' not in self.__security['signMetadata']) or ('certFileName' not in self.__security['signMetadata'])):
                raise OneLogin_Saml2_Error('Invalid Setting: signMetadata value of the sp is not valid', OneLogin_Saml2_Error.SETTINGS_INVALID_SYNTAX)
            key_file_name = self.__security['signMetadata']['keyFileName']
            cert_file_name = self.__security['signMetadata']['certFileName']
            key_metadata_file = (self.__paths['cert'] + key_file_name)
            cert_metadata_file = (self.__paths['cert'] + cert_file_name)
            try:
                with open(key_metadata_file, 'r') as f_metadata_key:
                    key_metadata = f_metadata_key.read()
            except IOError:
                raise OneLogin_Saml2_Error('Private key file not readable: %s', OneLogin_Saml2_Error.PRIVATE_KEY_FILE_NOT_FOUND, key_metadata_file)
            try:
                with open(cert_metadata_file, 'r') as f_metadata_cert:
                    cert_metadata = f_metadata_cert.read()
            except IOError:
                raise OneLogin_Saml2_Error('Public cert file not readable: %s', OneLogin_Saml2_Error.PUBLIC_CERT_FILE_NOT_FOUND, cert_metadata_file)
        signature_algorithm = self.__security['signatureAlgorithm']
        digest_algorithm = self.__security['digestAlgorithm']
        metadata = OneLogin_Saml2_Metadata.sign_metadata(metadata, key_metadata, cert_metadata, signature_algorithm, digest_algorithm)
    return metadata
Gets the SP metadata. The XML representation.
:returns: SP metadata (xml)
:rtype: string
def get_sp_metadata(self):
    '\n        Gets the SP metadata. The XML representation.\n        :returns: SP metadata (xml)\n        :rtype: string\n        '
    metadata = OneLogin_Saml2_Metadata.builder(self.__sp, self.__security['authnRequestsSigned'], self.__security['wantAssertionsSigned'], self.__security['metadataValidUntil'], self.__security['metadataCacheDuration'], self.get_contacts(), self.get_organization())
    add_encryption = (self.__security['wantNameIdEncrypted'] or self.__security['wantAssertionsEncrypted'])
    cert_new = self.get_sp_cert_new()
    metadata = OneLogin_Saml2_Metadata.add_x509_key_descriptors(metadata, cert_new, add_encryption)
    cert = self.get_sp_cert()
    metadata = OneLogin_Saml2_Metadata.add_x509_key_descriptors(metadata, cert, add_encryption)
    if (('signMetadata' in self.__security) and (self.__security['signMetadata'] is not False)):
        if (self.__security['signMetadata'] is True):
            if (not cert):
                raise OneLogin_Saml2_Error('Cannot sign metadata: missing SP public key certificate.', OneLogin_Saml2_Error.PUBLIC_CERT_FILE_NOT_FOUND)
            cert_metadata = cert
            key_metadata = self.get_sp_key()
            if (not key_metadata):
                raise OneLogin_Saml2_Error('Cannot sign metadata: missing SP private key.', OneLogin_Saml2_Error.PRIVATE_KEY_FILE_NOT_FOUND)
        else:
            if (('keyFileName' not in self.__security['signMetadata']) or ('certFileName' not in self.__security['signMetadata'])):
                raise OneLogin_Saml2_Error('Invalid Setting: signMetadata value of the sp is not valid', OneLogin_Saml2_Error.SETTINGS_INVALID_SYNTAX)
            key_file_name = self.__security['signMetadata']['keyFileName']
            cert_file_name = self.__security['signMetadata']['certFileName']
            key_metadata_file = (self.__paths['cert'] + key_file_name)
            cert_metadata_file = (self.__paths['cert'] + cert_file_name)
            try:
                with open(key_metadata_file, 'r') as f_metadata_key:
                    key_metadata = f_metadata_key.read()
            except IOError:
                raise OneLogin_Saml2_Error('Private key file not readable: %s', OneLogin_Saml2_Error.PRIVATE_KEY_FILE_NOT_FOUND, key_metadata_file)
            try:
                with open(cert_metadata_file, 'r') as f_metadata_cert:
                    cert_metadata = f_metadata_cert.read()
            except IOError:
                raise OneLogin_Saml2_Error('Public cert file not readable: %s', OneLogin_Saml2_Error.PUBLIC_CERT_FILE_NOT_FOUND, cert_metadata_file)
        signature_algorithm = self.__security['signatureAlgorithm']
        digest_algorithm = self.__security['digestAlgorithm']
        metadata = OneLogin_Saml2_Metadata.sign_metadata(metadata, key_metadata, cert_metadata, signature_algorithm, digest_algorithm)
    return metadata