Makes a encrypted assertion only containing self contained
        namespaces.

        :param assertion_tag: Tag for the assertion to be transformed.
        :return: A new samlp.Resonse in string representation.
422373
def get_xml_string_with_self_contained_assertion_within_encrypted_assertion(
            self, assertion_tag):
        
        prefix_map = self.get_prefix_map(
            [self.encrypted_assertion._to_element_tree().find(assertion_tag)])

        tree = self._to_element_tree()

        self.set_prefixes(
            tree.find(
                self.encrypted_assertion._to_element_tree().tag).find(
                assertion_tag), prefix_map)

        return ElementTree.tostring(tree, encoding="UTF-8").decode('utf-8')
968306
function assert(value, schema, message, vars) {
	return assertion(value, schema, message, vars, (internals.debug ? null : assert));
}
132278
public String extractTag(String tag) throws NaaccrIOException {
        if (tag == null)
            throw new NaaccrIOException("missing tag");
        int idx = tag.indexOf(':');
        if (idx != -1) {
            String namespace = tag.substring(0, idx), cleanTag = tag.substring(idx + 1);
            // check for the namespace only if the tag is a default one (Patient, Tumor, etc...) or if extensions are enabled
            if (_configuration.getAllowedTagsForNamespacePrefix(null).contains(cleanTag) || !Boolean.TRUE.equals(_options.getIgnoreExtensions())) {
                Set<String> allowedTags = _configuration.getAllowedTagsForNamespacePrefix(namespace);
                if (allowedTags == null || !allowedTags.contains(cleanTag))
                    throw new NaaccrIOException("tag '" + cleanTag + "' is not allowed for namespace '" + namespace + "'");
            }
            return cleanTag;
        }
        else {
            if (Boolean.TRUE.equals(_options.getUseStrictNamespaces()) && !_configuration.getAllowedTagsForNamespacePrefix(null).contains(tag))
                throw new NaaccrIOException("tag '" + tag + "' needs to be defined within a namespace");
            return tag;
        }
    }
807762
public function getAssertion(XMLSecurityKey $inputKey, array $blacklist = []) : Assertion
    {
        $assertionXML = Utils::decryptElement($this->encryptedData, $inputKey, $blacklist);

        Utils::getContainer()->debugMessage($assertionXML, 'decrypt');

        return new Assertion($assertionXML);
    }
1144955
def find_encrypt_data_assertion_list(self, _assertions):
        
        for _assertion in _assertions:
            if _assertion.advice:
                if _assertion.advice.encrypted_assertion:
                    res = self.find_encrypt_data_assertion(
                        _assertion.advice.encrypted_assertion)
                    if res:
                        return True
775731
def create_html_from_fragment(tag):
    

    try:
        assert isinstance(tag, bs4.element.Tag)
    except AssertionError:
        raise TypeError
    try:
        assert tag.find_all('body') == []
    except AssertionError:
        raise ValueError

    soup = BeautifulSoup('<html><head></head><body></body></html>', 'html.parser')
    soup.body.append(tag)
    return soup
128300
def parse_assertion(self, keys=None):
        
        if self.context == "AuthnQuery":
            # can contain one or more assertions
            pass
        else:
            # This is a saml2int limitation
            try:
                assert (
                    len(self.response.assertion) == 1
                    or len(self.response.encrypted_assertion) == 1
                    or self.assertion is not None
                )
            except AssertionError:
                raise Exception("No assertion part")

        if self.response.assertion:
            logger.debug("***Unencrypted assertion***")
            for assertion in self.response.assertion:
                if not self._assertion(assertion, False):
                    return False

        if self.find_encrypt_data(self.response):
            logger.debug("***Encrypted assertion/-s***")
            _enc_assertions = []
            resp = self.response
            decr_text = str(self.response)

            decr_text_old = None
            while self.find_encrypt_data(resp) and decr_text_old != decr_text:
                decr_text_old = decr_text
                try:
                    decr_text = self.sec.decrypt_keys(decr_text, keys)
                except DecryptError as e:
                    continue
                else:
                    resp = samlp.response_from_string(decr_text)
                    # check and prepare for comparison between str and unicode
                    if type(decr_text_old) != type(decr_text):
                        if isinstance(decr_text_old, six.binary_type):
                            decr_text_old = decr_text_old.decode("utf-8")
                        else:
                            decr_text_old = decr_text_old.encode("utf-8")

            _enc_assertions = self.decrypt_assertions(
                resp.encrypted_assertion, decr_text
            )

            decr_text_old = None
            while (
                self.find_encrypt_data(resp)
                or self.find_encrypt_data_assertion_list(_enc_assertions)
            ) and decr_text_old != decr_text:
                decr_text_old = decr_text
                try:
                    decr_text = self.sec.decrypt_keys(decr_text, keys)
                except DecryptError as e:
                    continue
                else:
                    resp = samlp.response_from_string(decr_text)
                    _enc_assertions = self.decrypt_assertions(
                        resp.encrypted_assertion, decr_text, verified=True
                    )
                    # check and prepare for comparison between str and unicode
                    if type(decr_text_old) != type(decr_text):
                        if isinstance(decr_text_old, six.binary_type):
                            decr_text_old = decr_text_old.decode("utf-8")
                        else:
                            decr_text_old = decr_text_old.encode("utf-8")

            all_assertions = _enc_assertions
            if resp.assertion:
                all_assertions = all_assertions + resp.assertion

            if len(all_assertions) > 0:
                for tmp_ass in all_assertions:
                    if tmp_ass.advice and tmp_ass.advice.encrypted_assertion:

                        advice_res = self.decrypt_assertions(
                            tmp_ass.advice.encrypted_assertion,
                            decr_text,
                            tmp_ass.issuer)
                        if tmp_ass.advice.assertion:
                            tmp_ass.advice.assertion.extend(advice_res)
                        else:
                            tmp_ass.advice.assertion = advice_res
                        if len(advice_res) > 0:
                            tmp_ass.advice.encrypted_assertion = []

            self.response.assertion = resp.assertion
            for assertion in _enc_assertions:
                if not self._assertion(assertion, True):
                    return False
                else:
                    self.assertions.append(assertion)

            self.xmlstr = decr_text
            if len(_enc_assertions) > 0:
                self.response.encrypted_assertion = []

        if self.response.assertion:
            for assertion in self.response.assertion:
                self.assertions.append(assertion)

        if self.assertions and len(self.assertions) > 0:
            self.assertion = self.assertions[0]

        if self.context == "AuthnReq" or self.context == "AttrQuery":
            self.ava = self.get_identity()
            logger.debug("--- AVA: %s", self.ava)

        return True
1304683
def create_tag(version: Union[Version, str], tag_format: Optional[str] = None):
    
    if isinstance(version, str):
        version = Version(version)

    if not tag_format:
        return version.public

    major, minor, patch = version.release
    prerelease = ""
    if version.is_prerelease:
        prerelease = f"{version.pre[0]}{version.pre[1]}"

    t = Template(tag_format)
    return t.safe_substitute(
        version=version, major=major, minor=minor, patch=patch, prerelease=prerelease
    )
1069451
def assert_match(actual_string, expected_re, message="")
      _wrap_assertion {
        full_message = build_message(message, "Expected <?> to match <?>", actual_string, expected_re)
        assert_block(full_message) {
          expected_re =~ actual_string
        }
        Regexp.last_match
      }
    end
727102
def webdriver_assert(self, assertion, failure_message='Failed Assertion'):
        
        try:
            assert assertion() is True
        except AssertionError:
            raise WebDriverAssertionException.WebDriverAssertionException(self.driver_wrapper, failure_message)

        return True
149184
private void copyAssertionAttributesToUserAttributes(Assertion assertion) {
        if (!copyAssertionAttributesToUserAttributes) {
            return;
        }

        // skip this if there are no attributes or if the attribute set is empty.
        if (assertion.getPrincipal().getAttributes() == null
                || assertion.getPrincipal().getAttributes().isEmpty()) {
            return;
        }

        Map<String, List<Object>> attributes = new HashMap<>();
        // loop over the set of person attributes from CAS...
        for (Map.Entry<String, Object> attrEntry :
                assertion.getPrincipal().getAttributes().entrySet()) {
            log.debug(
                    "Adding attribute '{}' from Assertion with value '{}'; runtime type of value is {}",
                    attrEntry.getKey(),
                    attrEntry.getValue(),
                    attrEntry.getValue().getClass().getName());

            // Check for credential
            if (decryptCredentialToPassword
                    && key != null
                    && cipher != null
                    && attrEntry.getKey().equals(CREDENTIAL_KEY)) {
                try {
                    final String encPwd =
                            (String)
                                    (attrEntry.getValue() instanceof List
                                            ? ((List) attrEntry.getValue()).get(0)
                                            : attrEntry.getValue());
                    byte[] cred64 = DatatypeConverter.parseBase64Binary(encPwd);
                    cipher.init(Cipher.DECRYPT_MODE, key);
                    final byte[] cipherData = cipher.doFinal(cred64);
                    final Object pwd = new String(cipherData, UTF_8);
                    attributes.put(PASSWORD_KEY, Collections.singletonList(pwd));
                } catch (Exception e) {
                    log.warn("Cannot decipher credential", e);
                }
            }

            // convert each attribute to a list, if necessary...
            List<Object> valueList;
            if (attrEntry.getValue() instanceof List) {
                valueList = (List<Object>) attrEntry.getValue();
            } else {
                valueList = Collections.singletonList(attrEntry.getValue());
            }

            // add the attribute...
            attributes.put(attrEntry.getKey(), valueList);
        }

        // get the attribute descriptor from Spring...
        IAdditionalDescriptors additionalDescriptors =
                (IAdditionalDescriptors)
                        applicationContext.getBean(SESSION_ADDITIONAL_DESCRIPTORS_BEAN);

        // add the new properties...
        additionalDescriptors.addAttributes(attributes);
    }
504773
def epp_namespace(node, name = nil, namespaces = {})
      return namespaces['epp'] if namespaces.has_key?('epp')
      xml_namespace(node, name, 'urn:ietf:params:xml:ns:epp-1.0')
    end
546866
def make_assertions(input_pipe, other_pipes, output_pipe):
        
        assert isinstance(input_pipe, elements.InPypElement), 'Wrong input element type, want a InPypElement!'
        assert isinstance(output_pipe, elements.OutPypElement), 'Wrong output element type, want a OutPypElement!'
        for other_pipe in other_pipes:
            assert isinstance(other_pipe, elements.MidPypElement), 'Wrong middle element type, want a MidPypElement!'
848686
def _fake_enumeratequalifiers(self, namespace, **params):
        # pylint: disable=unused-argument
        

        # Validate namespace
        qualifier_repo = self._get_qualifier_repo(namespace)

        qualifiers = list(qualifier_repo.values())

        return self._make_tuple(qualifiers)
1319380
def _assertion(self, assertion, verified=False):
        

        if not hasattr(assertion, 'signature') or not assertion.signature:
            logger.debug("unsigned")
            if self.require_signature:
                raise SignatureError("Signature missing for assertion")
        else:
            logger.debug("signed")
            if not verified and self.do_not_verify is False:
                try:
                    self.sec.check_signature(assertion, class_name(assertion),
                                             self.xmlstr)
                except Exception as exc:
                    logger.error("correctly_signed_response: %s", exc)
                    raise

        self.assertion = assertion
        logger.debug("assertion context: %s", self.context)
        logger.debug("assertion keys: %s", assertion.keyswv())
        logger.debug("outstanding_queries: %s", self.outstanding_queries)

        # if self.context == "AuthnReq" or self.context == "AttrQuery":
        if self.context == "AuthnReq":
            self.authn_statement_ok()
        # elif self.context == "AttrQuery":
        #            self.authn_statement_ok(True)

        if not self.condition_ok():
            raise VerificationError("Condition not OK")

        logger.debug("--- Getting Identity ---")

        # if self.context == "AuthnReq" or self.context == "AttrQuery":
        #    self.ava = self.get_identity()
        #    logger.debug("--- AVA: %s", self.ava)

        try:
            self.get_subject()
            if self.asynchop:
                if self.allow_unsolicited:
                    pass
                elif self.came_from is None:
                    raise VerificationError("Came from")
            return True
        except Exception:
            logger.exception("get subject")
            raise
124878
def generate_xmltags(fn, returntag, ignore_tags, ns=None):
    
    xmlns = create_namespace(ns)
    ns_ignore = ['{0}{1}'.format(xmlns, x) for x in ignore_tags]
    for ac, el in etree.iterparse(fn):
        if el.tag == '{0}{1}'.format(xmlns, returntag):
            yield el
        elif el.tag in ns_ignore:
            formatting.clear_el(el)
884244
def build_payload(self, tag, message):
        
        message = self.encode(message)
        message = self.sign(message)
        payload = bytes(tag.encode('utf-8')) + message
        return payload