Did I find the right examples for you? yes no

All Samples(34)  |  Call(20)  |  Derive(0)  |  Import(14)

        def valid_instance(instance):
    instclass = instance.__class__
    class_name = instclass.__name__

    # if instance.text:
    #     _has_val = True
    # else:
    #     _has_val = False

    if instclass.c_value_type and instance.text:
        try:
            validate_value_type(instance.text.strip(),
                                instclass.c_value_type)
        except NotValid, exc:
            raise NotValid("Class '%s' instance: %s" % (class_name,
                                                        exc.args[0]))

    for (name, typ, required) in instclass.c_attributes.values():
        value = getattr(instance, name, '')
        if required and not value:
            txt = "Required value on property '%s' missing" % name
            raise MustValueError("Class '%s' instance: %s" % (class_name, txt))
        
        if value:
            try:
                if isinstance(typ, type):
                    if typ.c_value_type:
                        spec = typ.c_value_type
                    else:
                        spec = {"base": "string"}  # do I need a default
              
                    validate_value_type(value, spec)
                else:
                    valid(typ, value)
            except (NotValid, ValueError), exc:
                txt = ERROR_TEXT % (value, name, exc.args[0])
                raise NotValid("Class '%s' instance: %s" % (class_name, txt))
        
    for (name, _spec) in instclass.c_children.values():
        value = getattr(instance, name, '')

        try:
            _card = instclass.c_cardinality[name]
            try:
                _cmin = _card["min"]
            except KeyError:
                _cmin = None
            try:
                _cmax = _card["max"]
            except KeyError:
                _cmax = None
        except KeyError:
            _cmin = _cmax = _card = None

        if value:
            #_has_val = True
            if isinstance(value, list):
                _list = True
                vlen = len(value)
            else:
                _list = False
                vlen = 1

            if _card:
                if _cmin is not None and _cmin > vlen:
                    raise NotValid(
                        "Class '%s' instance cardinality error: %s" % (
                            class_name, "less then min (%s<%s)" % (vlen,
                                                                   _cmin)))
                if _cmax is not None and vlen > _cmax:
                    raise NotValid(
                        "Class '%s' instance cardinality error: %s" % (
                            class_name, "more then max (%s>%s)" % (vlen,
                                                                   _cmax)))
            
            if _list:
                for val in value:
                    # That it is the right class is handled elsewhere
                    _valid_instance(instance, val)
            else:
                _valid_instance(instance, value)
        else:
            if _cmin:
                raise NotValid(
                    "Class '%s' instance cardinality error: %s" % (
                        class_name, "too few values on %s" % name))

#    if not _has_val:
#        if class_name != "RequestedAttribute":
#            # Not allow unless xsi:nil="true"
#            assert instance.extension_attributes
#            assert instance.extension_attributes[XSI_NIL] == "true"

    return True
        


src/p/y/pysaml2-2.0.0/src/saml2/response.py   pysaml2(Download)
from saml2.validate import validate_on_or_after
from saml2.validate import validate_before
from saml2.validate import valid_instance
from saml2.validate import valid_address
from saml2.validate import NotValid
 
        try:
            valid_instance(self.response)
        except NotValid, exc:
            logger.error("Not valid response: %s" % exc.args[0])
    def verify(self):
        try:
            valid_instance(self.response)
        except NotValid, exc:
            logger.error("Not valid response: %s" % exc.args[0])

src/p/y/pysaml2-HEAD/src/saml2/response.py   pysaml2(Download)
from saml2.validate import validate_on_or_after
from saml2.validate import validate_before
from saml2.validate import valid_instance
from saml2.validate import valid_address
from saml2.validate import NotValid
 
        try:
            valid_instance(self.response)
        except NotValid as exc:
            logger.error("Not valid response: %s" % exc.args[0])
    def verify(self, key_file=""):
        try:
            valid_instance(self.response)
        except NotValid as exc:
            logger.error("Not valid response: %s" % exc.args[0])

src/p/y/pysaml2-2.0.0/src/saml2/metadata.py   pysaml2(Download)
#!/usr/bin/env python
from saml2.sigver import security_context
from saml2.config import Config
from saml2.validate import valid_instance
from saml2.time_util import in_a_while
        desc = entities_descriptor(eds, valid_for, name, mid,
                                   sign, secc)
        valid_instance(desc)
 
        return metadata_tostring_fix(desc, nspair)
            else:
                desc = eid
            valid_instance(desc)
            return metadata_tostring_fix(desc, nspair)
 

src/p/y/pysaml2-HEAD/src/saml2/metadata.py   pysaml2(Download)
#!/usr/bin/env python
from saml2.sigver import security_context
from saml2.config import Config
from saml2.validate import valid_instance
from saml2.time_util import in_a_while
        desc = entities_descriptor(eds, valid_for, name, mid,
                                   sign, secc)
        valid_instance(desc)
 
        return metadata_tostring_fix(desc, nspair)
            else:
                desc = eid
            valid_instance(desc)
            return metadata_tostring_fix(desc, nspair)
 

src/p/y/pysaml2-2.0.0/tools/make_metadata.py   pysaml2(Download)
 
from saml2.sigver import security_context
from saml2.validate import valid_instance
from saml2.config import Config
 
    desc = entities_descriptor(eds, valid_for, args.name, args.id,
                               args.sign, secc)
    valid_instance(desc)
    print desc.to_string(nspair)
else:
        else:
            desc = eid
        valid_instance(desc)
        print desc.to_string(nspair)
 

src/p/y/pysaml2-HEAD/tools/make_metadata.py   pysaml2(Download)
 
from saml2.sigver import security_context
from saml2.validate import valid_instance
from saml2.config import Config
 
    desc = entities_descriptor(eds, valid_for, args.name, args.id,
                               args.sign, secc)
    valid_instance(desc)
    print desc.to_string(nspair)
else:
        else:
            desc = eid
        valid_instance(desc)
        print desc.to_string(nspair)
 

src/p/y/pysaml2-2.0.0/src/saml2/request.py   pysaml2(Download)
from saml2.s_utils import OtherError
 
from saml2.validate import valid_instance
from saml2.validate import NotValid
from saml2.response import IncorrectlySigned
 
        try:
            valid_instance(self.message)
        except NotValid, exc:
            logger.error("Not valid request: %s" % exc.args[0])

src/p/y/pysaml2-2.0.0/src/saml2/mdstore.py   pysaml2(Download)
from saml2.s_utils import UnsupportedBinding, UnknownPrincipal
from saml2.sigver import split_len
from saml2.validate import valid_instance
from saml2.time_util import valid
from saml2.validate import NotValid
        else:
            try:
                valid_instance(self.entities_descr)
            except NotValid, exc:
                logger.error(exc.args[0])

src/p/y/pysaml2-HEAD/src/saml2/request.py   pysaml2(Download)
from saml2.s_utils import OtherError
 
from saml2.validate import valid_instance
from saml2.validate import NotValid
from saml2.response import IncorrectlySigned
 
        try:
            valid_instance(self.message)
        except NotValid, exc:
            logger.error("Not valid request: %s" % exc.args[0])

src/p/y/pysaml2-HEAD/src/saml2/mdstore.py   pysaml2(Download)
from saml2.s_utils import UnsupportedBinding, UnknownPrincipal
from saml2.sigver import split_len
from saml2.validate import valid_instance
from saml2.time_util import valid
from saml2.validate import NotValid
        else:
            try:
                valid_instance(self.entities_descr)
            except NotValid, exc:
                logger.error(exc.args[0])

  1 | 2  Next