Exemplo n.º 1
0
    def create_claim_type(name):
        from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType

        try:
            if not ClaimType.name_exists(name):
                claim_type = ClaimType()
                claim_type.name = name
                ClaimType.create(claim_type)
                return claim_type
        except Exception as ex:
            pass
Exemplo n.º 2
0
 def is_sys_admin(self):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     sys_admin_claim_type = ClaimType.get_role()
     for claim in self.claims:
         if claim.claim_type_id == sys_admin_claim_type._id and claim.value == "SYSADMIN":
             return True
     return False
Exemplo n.º 3
0
 def claim_add_by_claim_type_name(self, claim_type_name, claim_value):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     claim_type = ClaimType.get_by_name(claim_type_name)
     claim = Claim()
     claim.claim_type_id = claim_type._id
     claim.value = claim_value
     self.claim_add(claim)
 def validate(self, claim_id):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     permission_claim_type = ClaimType.get_permission()
     resource = Resource()
     resource._id = self.resource_id
     claim_is_of_claim_type = resource.claim_is_of_claim_type(claim_id, permission_claim_type._id)
     if claim_is_of_claim_type:
         super().custom.manual(ResourceErrorCodes.RESOURCE_CLAIM_WITH_PERMISSION_CLAIM_TYPE_IS_NOT_REMOVABLE)
Exemplo n.º 5
0
    def create(self):
        from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType

        resource = Resource()
        permission_claim_type = ClaimType.get_permission()
        resource_default_claim = Claim()
        resource_default_claim.claim_type_id = permission_claim_type._id
        resource_default_claim.value = self.name
        resource.claims.append(resource_default_claim)
        resource_writer.create(self)
Exemplo n.º 6
0
    def create(self):
        from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType

        user_name_claim_type = ClaimType.get_by_name("USER_NAME")

        user_default_claim = Claim()
        user_default_claim.claim_type_id = user_name_claim_type._id
        user_default_claim.value = self.user_name

        self.claims.append(user_default_claim)

        user_writer.create(self)
Exemplo n.º 7
0
    def create(self):
        from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType

        user_name_claim_type = ClaimType.get_by_name("USER_NAME")

        user_default_claim = Claim()
        user_default_claim.claim_type_id = user_name_claim_type._id
        user_default_claim.value = self.user_name
        self.claims.append(user_default_claim)

        self.status = Status.activated
        bcrypt = Bcrypt(None)
        password_hash = bcrypt.generate_password_hash(self.password)
        self.password = password_hash
        user_writer.create(self)
Exemplo n.º 8
0
 def validate(self, name):
     is_name_exist = ClaimType.name_exists(name)
     if is_name_exist:
         super().custom.manual(ClaimTypeErrorCodes.CLAIM_TYPE_NAME_EXIST)
Exemplo n.º 9
0
 def validate(self, _id):
     is_available_id = ClaimType.id_exists(_id)
     if not is_available_id:
         super().custom.manual(ClaimTypeErrorCodes.CLAIM_TYPE_ID_NOT_EXIST)
Exemplo n.º 10
0
 def claims_get_by_claim_type_name(self, claim_type_name):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     claim_type = ClaimType.get_by_name(claim_type_name)
     return user_reader.claims_get_claim_type_id(self._id, claim_type._id)
Exemplo n.º 11
0
 def claim_edit_by_claim_type_name_with_value(self, claim_type_name, claim_old_value, claim_value):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     claim_type = ClaimType.get_by_name(claim_type_name)
     user_writer.claim_edit_by_claim_type_name_with_value(self._id, claim_type._id, claim_old_value, claim_value)
 def validate(self, claim_type_id):
     claim_type = ClaimType.get_by_id(claim_type_id)
     if claim_type.name == "PERMISSION":
         super().custom.manual(ClaimTypeErrorCodes.PERMISSION_CLAIM_TYPE_IS_NOT_REMOVABLE)
Exemplo n.º 13
0
 def claim_type_get(self):
     from pyclaim.domain.aggregates.claim_type.model.claim_type import ClaimType
     return ClaimType.get_by_id(self.claim_type_id)
Exemplo n.º 14
0
 def execute(self):
     claim_type = ClaimType()
     claim_type.name = self.name
     claim_type.create()
     return claim_type._id
Exemplo n.º 15
0
 def execute(self):
     claim_type = ClaimType()
     claim_type._id = self._id
     claim_type.remove()
     return "Done"
Exemplo n.º 16
0
 def execute(self):
     claim_types = ClaimType.get_all()
     claim_types_detail = ClaimTypeDetail.create_from_claim_types(claim_types)
     return claim_types_detail