return a SecurityError if the specified securityData element has one, else return None
167494
def get_security_error(node):
        
        assert node.name() == 'securityData' and not node.isArray()
        if node.hasElement('securityError'):
            secid = XmlHelper.get_child_value(node, 'security')
            err = XmlHelper.as_security_error(node.getElement('securityError'), secid)
            return err
        else:
            return None
518134
def __decrypt_assertion(self, dom):
        
        key = self.__settings.get_sp_key()
        debug = self.__settings.is_debug_active()

        if not key:
            raise OneLogin_Saml2_Error(
                'No private key available to decrypt the assertion, check settings',
                OneLogin_Saml2_Error.PRIVATE_KEY_NOT_FOUND
            )

        encrypted_assertion_nodes = OneLogin_Saml2_Utils.query(dom, '/samlp:Response/saml:EncryptedAssertion')
        if encrypted_assertion_nodes:
            encrypted_data_nodes = OneLogin_Saml2_Utils.query(encrypted_assertion_nodes[0], '//saml:EncryptedAssertion/xenc:EncryptedData')
            if encrypted_data_nodes:
                keyinfo = OneLogin_Saml2_Utils.query(encrypted_assertion_nodes[0], '//saml:EncryptedAssertion/xenc:EncryptedData/ds:KeyInfo')
                if not keyinfo:
                    raise OneLogin_Saml2_ValidationError(
                        'No KeyInfo present, invalid Assertion',
                        OneLogin_Saml2_ValidationError.KEYINFO_NOT_FOUND_IN_ENCRYPTED_DATA
                    )
                keyinfo = keyinfo[0]
                children = keyinfo.getchildren()
                if not children:
                    raise OneLogin_Saml2_ValidationError(
                        'KeyInfo has no children nodes, invalid Assertion',
                        OneLogin_Saml2_ValidationError.CHILDREN_NODE_NOT_FOUND_IN_KEYINFO
                    )
                for child in children:
                    if 'RetrievalMethod' in child.tag:
                        if child.attrib['Type'] != 'http://www.w3.org/2001/04/xmlenc#EncryptedKey':
                            raise OneLogin_Saml2_ValidationError(
                                'Unsupported Retrieval Method found',
                                OneLogin_Saml2_ValidationError.UNSUPPORTED_RETRIEVAL_METHOD
                            )
                        uri = child.attrib['URI']
                        if not uri.startswith('#'):
                            break
                        uri = uri.split('#')[1]
                        encrypted_key = OneLogin_Saml2_Utils.query(encrypted_assertion_nodes[0], './xenc:EncryptedKey[@Id=$tagid]', None, uri)
                        if encrypted_key:
                            keyinfo.append(encrypted_key[0])

                encrypted_data = encrypted_data_nodes[0]
                decrypted = OneLogin_Saml2_Utils.decrypt_element(encrypted_data, key, debug=debug, inplace=True)
                dom.replace(encrypted_assertion_nodes[0], decrypted)

        return dom
1088120
function findErrorObj(data) {
  if (notObjectOrIsEmpty(data)) {
    return false;
  }
  // Only the attributes, not the data itself.
  for (let key in data) {
    let attr = data[key];
    const found = parseError.findErrorObj(attr);
    if (found) {
      return found;
    }
  }
  // Not found.
  return false;
}
184853
function(item) {
        if (item && Selectivity.isValidId(item.id) && isString(item.text)) {
            return item;
        } else {
            throw new Error('Item should have id (number or string) and text (string) properties');
        }
    }
1093910
def _check_err(data):
    
    if data['d'] is None:
        raise NoDataReturned()
    if data['d']['Messages'] is None:
        return

    msg = data['d']['Messages']
    if len(msg) == 0 or msg[0]['Code'] is None:
        raise UnknownError()

    code = int(msg[0]['Code'])
    if code == 3006:
        raise CalendarNotExist()
    elif code == 3007:
        raise CalendarOwnByDiffAccount()
    else:
        logger.warn(
            "Unexpected Error Code: %s %s" % (
                code, msg[0]['Description']))
        raise UnexpectedError()
514472
def assertNotCookie(self, name, value=None, attrs={}, *args, **kwargs):
        
        return not self.assertCookie(name, value, attrs)
684823
def validate_driver_or_none(option, value):
    """"""
    if value is None:
        return value
    if not isinstance(value, DriverInfo):
        raise TypeError("%s must be an instance of DriverInfo" % (option,))
    return value
806065
public void updateErrorTemplate(int statusCode, String template) throws SecurityException {
	checkWriteAccess();
	boolean hasAccess = ConfigWebUtil.hasAccess(config, SecurityManager.TYPE_DEBUGGING);
	if (!hasAccess) throw new SecurityException("no access to change error settings");

	Element error = _getRootElement("error");
	// if(template.trim().length()>0)
	error.setAttribute("template-" + statusCode, template);
    }
857579
def validate_none(b):
    """"""
    if isinstance(b, six.string_types):
        b = b.lower()
    if b is None or b == 'none':
        return None
    else:
        raise ValueError('Could not convert "%s" to None' % b)
555645
def SecurityCheck(self, func, request, *args, **kwargs):
    """"""
    if self.IAP_HEADER not in request.headers:
      return werkzeug_wrappers.Response("Unauthorized", status=401)

    jwt = request.headers.get(self.IAP_HEADER)
    try:
      request.user, _ = validate_iap.ValidateIapJwtFromComputeEngine(
          jwt, self.cloud_project_id, self.backend_service_id)
      return func(request, *args, **kwargs)

    except validate_iap.IAPValidationFailedError as e:
      # Return failure if IAP is not decoded correctly.
      logging.error("IAPWebAuthManager failed with: %s", e)
      return werkzeug_wrappers.Response("Unauthorized", status=401)
120980
def extract_error(checker, *a, **kw):
    

    res = catch_error(checker, *a, **kw)
    if isinstance(res, DataError):
        return res.as_dict()
    return res
1122819
function isErrorElement( $elementID, &$installParameters )
    {
        if ( $elementID == $installParameters['error']['element_id'] )
        {
            // If action not set - skip this element
            if ( !isset( $installParameters['error']['choosen_action'] ) )
            {
                 $installParameters['error'] = array();
                 return false;
            }
            return true;
        }
        return false;

    }
707018
def _def_check(self):
        
        if self._def != dict():
            for key, val in iteritems_(self._def):
                if key not in list(TEXT_INDEX_ARGS.keys()):
                    raise CloudantArgumentError(127, key)
                if not isinstance(val, TEXT_INDEX_ARGS[key]):
                    raise CloudantArgumentError(128, key, TEXT_INDEX_ARGS[key])
48396
def matches(self, object):
    

    try:
      self.check_match(object)
    except securesystemslib.exceptions.FormatError:
      return False
    else:
      return True
242005
private boolean accept(SecurityContext securityContext, T element) {

		boolean ret = true;

		for(Filter<T> predicate : filters) {

			predicate.setSecurityContext(securityContext);
			ret &= predicate.accept(element);
		}

		return(ret);
	}
536026
def prepare_check(data):
    
    if not data:
        return None, {}

    if isinstance(data, str):
        return data, {}

    result = {}
    if "ID" in data:
        result["CheckID"] = data["ID"]
    for k in ("Node", "CheckID", "Name", "Notes", "Status", "ServiceID"):
        if k in data:
            result[k] = data[k]
    if list(result) == ["CheckID"]:
        return result["CheckID"], {}
    return result.get("CheckID"), result
213868
def _mask_invalid(self, data, header):
        """"""
        invalid = da.logical_or(data == header['block5']["count_value_outside_scan_pixels"][0],
                                data == header['block5']["count_value_error_pixels"][0])
        return da.where(invalid, np.float32(np.nan), data)